could not access textbox text in TemplateField
.aspx:
<asp:TemplateField HeaderText="PIN" AccessibleHeaderText="PIN">
<ItemTemplate>
<asp:TextBox ID="txtPin" runat="server" Width="50px" MaxLength="4"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
code behind:
foreach (GridViewRow gr in grdPin.Rows)
{
TextBox lblDate = (TextBox)gr.Cells[0].FindControl("txtPin");
string x = lblDate.Text;
}
variable x is null.