//........Server side code.........
protected void row_click(object sender, GridViewCommandEventArgs e)
{
string hiddenFieldValue = ((HiddenField) grdname.Rows[0].FindControl("showfieldid")).Value;
or
string hiddenFieldValue = ((HiddenField)grdname.Rows[((GridViewRow)(((LinkButton)e.CommandSource).NamingContainer)).RowIndex].FindControl("showfieldid")).Value;
}
//........Client side code.........
<asp:GridView ID="grdname" runat="server" AutoGenerateColumns="False" EmptyDataText="No data found" OnRowCommand="row_click">
<Columns>
<asp:TemplateField HeaderText="templateheader" ItemStyle-HorizontalAlign="left" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="showfieldname" runat="server" Text=' <%# DataBinder.Eval(Container.DataItem, " showfield_name")%>'></asp:LinkButton>
<asp:HiddenField ID="showfieldid" runat="server" Value=' <%# DataBinder.Eval(Container.DataItem, " showfield_id")%>'>
</asp:HiddenField>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
No comments:
Post a Comment