SearchForKnowledge
SearchForKnowledge

Reputation: 3751

How to get the first column value of a selected row in GridView

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

Answers (1)

Med.Amine.Touil
Med.Amine.Touil

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

Related Questions