Good day
I have gridview that contains a link button. How can I retrieve the value(Text) of the link button when I click on it.
This is what I have done.
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkProdCode" CommandName="ProdCode" runat="server" Width="115%" Text='<%# DataBinder.Eval(Container.DataItem,"CODE") %>' style="color:Black;font-size:smaller;"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
protected void gridReport_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ProdCode")
{
GridViewRow selectedRow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
string valueLink = selectedRow.Cells[0].Text;
System.Diagnostics.Debug.WriteLine("This is the value " + valueLink);
}
}
As it is at the moment I dont get the value.
You already have the LinkButton, just use the
Textproperty