In this blog we will know the value of link button in a Grid view.
Scenario
I have a grid view with username as the link button in a template field. When user clicks on the link button then username value, which is a link button, will be displayed in a label control.
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!DOCTYPE html
PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
onselectedindexchanging="GridView1_SelectedIndexChanging" DataKeyNames="empname">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:LinkButton ID="lnkSelect" Text="" CommandName="Select" runat="server">
<%#Eval("empname")%>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>

Join the conversation! Your thoughts help the community grow.