I have GridView with Template Column.Inside the template column i have asp:hiddenfield. I am binding the value using Eval() method.When i am trying to access the value of hiddenfi not accesible while visibility false
ASPX
<asp:TemplateField HeaderText="Select" Visible="false">
<ItemTemplate>
<asp:HiddenField ID="hdnMasterId" runat="server"
Value='<%# DataBinder.Eval(Container.DataItem, "Master_Id") %>' />
<asp:CheckBox ID="chkDelete" runat="server" />
</ItemTemplate>
<ItemStyle Width="4%" HorizontalAlign="Center"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
CODE BEHIND
protected void gdvList_RowCommand(object sender, GridViewCommandEventArgs e)
{
int intIndex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gdvList.Rows[intIndex];
HiddenField hdn = (HiddenField)row.FindControl("hdnMasterId");
}
If you set visibility=”false” on a column it won’t generate any html, thus wont have the hidden control. You need to put the hiddenfield elsewhere or hide the column with css/style instead.