I am working on an asp.net c# WebForms application. The form has two controls, a GridView and a FormView. The FormView is populated when a row is selected in the GridView. This all works as expected. The problem is that I need the value of the Id field from the GridView to be the value of a field in the FormView's InsertItemTemplate. The following passes the Id of the GridView (venId) to the HiddenField on SelectedIndexChanged:
protected void rg_vendors_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridDataItem item in rg_vendors.Items)
{
hdn_ven_id.Value = item["venId"].Text;
}
}
Next I would like to set the value of the venIdFk field in the FormViewto be equal to the value of hdn_ven_id when inserting the FormView data into the database. I don't know how to get this done, but here is an idea of what I need:
protected void fv_vc_ItemInsert(object sender, FormViewInsertEventArgs e)
{
(TextBox)fv_vc.FindControl("venIdFk") = hdn_ven_id.Value;
}
The formview is fv_vc
The gridview is rg_vendors
The hidden field is hdn_ven_id
This is an asp.net c# webforms application
I am using VS2013