The aspx page
<asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="btnTemplate" runat="server" OnClick="btnTemplate_Click">LinkButton</asp:LinkButton> </ItemTemplate> </asp:TemplateField>
The C# code behind
protected void btnTemplate_Click(object sender, EventArgs e) { //Clear Selection GridView1.SelectedIndex = -1; // Get the checkbox that was Selected LinkButton btnTemplate = (LinkButton)sender; // As this is a template column, we can get the specifc row by using the Naming Container GridViewRow selectedGridRow = (GridViewRow)btnTemplate.NamingContainer; // get the userID from the first column that is hidden by CSS Response.Write(selectedGridRow.Cells[0].Text); }
