Link to home
Start Free TrialLog in
Avatar of Mike_Stevens
Mike_StevensFlag for United States of America

asked on

Link Button in Gridview Template Column

I have a template column in a asp.net web form that has a link button in it.  when I click on the link button I want to read the value from the third column for the current row. The following code works fine in a command column of the grid but not from the template column:

 Dim x As String = Me.GridView1.Rows(Me.GridView1.SelectedRow.RowIndex).Cells(3).Text
     
If I use this in the template column it returns an error.

What am I doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of Monica P
Monica P
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Deja Anbu
say if your third column contains a label which displays your desired value, then


Dim x As String =CType(GridView1.SelectedRow.FindControl("YourLabel"), Label).Text