Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to use button control in datalist
Posted

in your .aspx

ASP.NET
<asp:datalist id="dlstProducts" runat="server" repeatcolumns="3" cellspacing="5" repeatdirection="Horizontal" repeatlayout="Table" onitemcommand="dlstProducts_ItemCommand">
<itemtemplate>
  <asp:button id="btnDetails" runat="server" commandname="Details" cssclass="RepeaterDetails" text="Details" commandargument="<%# Eval("ID") %>"></asp:button>
</itemtemplate>
</asp:datalist>

in .cs

C#
protected void dlstProducts_ItemCommand(object source, DataListCommandEventArgs e)
{
   if (e.CommandName == "Details")
     {
       string value = (string)e.CommandArgument;
     }
}
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900