Hot to get the Gridview linkbutton get selected Row?

To get the GridViewRow of a selected item Template, set an OnClick to a method to handle the event.

i.e.

 

In the method you can reference the clicked link button by using the following code:

[codesyntax lang=”csharp”]

GridViewRow row = (GridViewRow)((Control)sender).NamingContainer;
string item = row.Cells[1].text;

[/codesyntax]

Author: Travis Gneiting

Passionate Professional .NET Developer