Reputation: 3751
I have a GridView
How do I get a value of a column for a given row.
I tried the following but it only gives the row number instead of the value:
int selRowIndex = ((GridViewRow)(((System.Web.UI.WebControls.CheckBox)sender).Parent.Parent)).RowIndex;
Upvotes: 1
Views: 1550
Reputation: 1235
you are looking for the contentnot the index
var cellText= ((GridViewRow)(((System.Web.UI.WebControls.CheckBox)sender).Parent.Parent)).Cells[0].Text;
and then convert it to int
Upvotes: 2