Quantcast
Viewing latest article 7
Browse Latest Browse All 8

Re: How do i access id value of gridview asp.net

I'm not sure if I follow. What are you trying to achieve? Your current could should work to get the values except that I don't know what's the object "item" is. To get the id from GridView then you need to set the DataKeyNames for the IDs that you want to use and access it like this:

//if you are passing rowindex in commandArgument
int index = Convert.ToInt32(e.CommandArgument);
string value = this.GridView1.DataKeys[index].Values["Key"].ToString();

//if you are not passing rowindex in commandArgument
index = ((sender as LinkButton).NamingContainer as GridViewRow).RowIndex;
string value = this.GridView1.DataKeys[index].Values["Key"].ToString();


Viewing latest article 7
Browse Latest Browse All 8

Trending Articles