4
Answers

How To Get ID from Gridview when Button Clicked

Chandan Kumar

Chandan Kumar

7y
724
1
I am Displaying all the Registered user in GridView from DB, along with an (ADD Friend) Image Button.
 
I want to Get ID The Particular User Where Image Button Clicked. 
 
How can I Get ID Field Data where the Add Button Click.
 
Please HELP ME.. 
Answers (4)
1
Kaushik Dhameliya

Kaushik Dhameliya

NA 1.4k 128.6k 7y
Hello chandan 
 
Try this
 
https://stackoverflow.com/a/466640 
1
shafeek ck

shafeek ck

1.4k 323 2.3k 7y
Add image button like this
 
<asp:ImageButton ID="imgbtnUser" runat="server" CommandName="User" CommandArgument='<%#Eval("UserID")%>'></asp:ImageButton> 
 
then read id like this
 
protected void grdUserList_RowCommand(object sender, GridViewCommandEventArgs e)
{
   if(e.CommandName.Equals("User"))
   {
      var UserID = e.CommandArgument.ToString();
   }
 
0
Chirag Rathod

Chirag Rathod

NA 151 2.5k 7y
When you need Id? You means click on imagre button of add column "+" sign ?
and you want to get id from clientside or server side? if client side you will use jquery . 
 
 
so please give me details about your question so i will help you.
 
Thank you
0
Chandan Kumar

Chandan Kumar

1.2k 485 598.2k 7y
Not Getting Your answer sir.....
Please help me