Mohan Chandra

Mohan Chandra

  • NA
  • 101
  • 16.8k

how we can get hidden field value to update records in DB

Sep 2 2016 5:53 AM
hi, i am using C# ASP.net ,
i have a form where two textboxes to save and then below a grid view where display the records now i want to this hidden field value during update a table records.

<asp:TemplateField HeaderText="From">
<ItemTemplate>
<asp:Label ID="lblfromdt" runat="server" Text='<%# Eval("FromDate", "{0:MMM-yyyy}")%>'></asp:Label>
<asp:HiddenField ID="CustomerId" runat="server" Value='<%# Bind("Id") %>' />
</ItemTemplate>
<ItemStyle CssClass="textAlignCenter" />
<HeaderStyle CssClass="textAlignCenter" />
</asp:TemplateField>
 
protected void grdFY_SelectedIndexChanged(object sender, EventArgs e)
{
string FromDT = (grdFY.SelectedRow.FindControl("lblfromdt") as Label).Text;
string ToDT = (grdFY.SelectedRow.FindControl("lbltodt") as Label).Text;
txtFinancialYearFrom.Text = FromDT;
txtFinancialYearTo.Text = ToDT;
string s = ((HiddenField)grdFY.SelectedRow.Cells[0].FindControl("CustomerId")).Value;
Id = Convert.ToInt16(s);
 
this Id value i want to pass on button click on same page outside of gridview.
please help me how i can 

Answers (2)