Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how can i bind "id" to a button in gridview?
Posted

1 solution

At Design page in grid view:
XML
<asp:button id="Button1" 
            runat="server"
            CommandArgument='<%#Eval("id")%>' 
            CommandName="arun" 
            Text="View Details" />

And Then Code page;
C#
protected void grd_question_RowCommand(object sender, GridViewCommandEventArgs e)
{
       if (e.CommandName == "arun";)
       {
           Int32 id = Convert.ToInt32(e.CommandArgument);

       }
}
 
Share this answer
 
v2
Comments
Sharon 2 21-Dec-12 1:21am    
thanks..
Arun kumar Gauttam 21-Dec-12 1:23am    
if you think that answer is right then plz accept my solution.

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