VD1234
asked on
Hidden field in a datagrid
I have a hidden field in a datagrid defined as follows:
<asp:TemplateColumn HeaderText="Index Field Names" ItemStyle-HorizontalAlign= "Center">
<ItemTemplate>
<asp:Label id="lblFieldName" runat="server" >
<input type="hidden" ID="hdnID" value='<%# DataBinder.Eval(Container, "DataItem.DocMapId") %>' runat="server" NAME="hdnID"/></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
Then in the backend, I try to access this hidden field as follows:
foreach (DataGridItem dgItem in dgdMapping.Items)
{
HtmlInputHidden hdnID = dgItem.Cells[0].FindContro l("hdnID") as HtmlInputHidden;
int intID = Convert.ToInt32(hdnID.Valu e);
}
But hdnID is assigned null. IT does not find the right control at right time.
How do I access the hidden value at run time through the datagrid.
Please help. Thanks in advance!
<asp:TemplateColumn HeaderText="Index Field Names" ItemStyle-HorizontalAlign=
<ItemTemplate>
<asp:Label id="lblFieldName" runat="server" >
<input type="hidden" ID="hdnID" value='<%# DataBinder.Eval(Container,
</ItemTemplate>
</asp:TemplateColumn>
Then in the backend, I try to access this hidden field as follows:
foreach (DataGridItem dgItem in dgdMapping.Items)
{
HtmlInputHidden hdnID = dgItem.Cells[0].FindContro
int intID = Convert.ToInt32(hdnID.Valu
}
But hdnID is assigned null. IT does not find the right control at right time.
How do I access the hidden value at run time through the datagrid.
Please help. Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forced accept.
Computer101
Community Support Moderator
Computer101
Community Support Moderator
ASKER
HtmlInputHidden hdnID = dgItem.Cells[0].FindContro
Thanks