I have a content page with a DropDownList in an UpdatePanel, a GridView in another UpdatePanel and a FormView in a 3rd UpdatePanel. The databind's for the 3 controls happen in the code behind.
The FormView is populated when a row is clicked in the grid. The Mode of the FormView is contolled by a series of buttons in that UpdatePanel, displayed as appropriate depending on the data in the grid row.
When the FormView is in Insert and the bound textboxes of that template are edited and (partial) posted back, I can retrieve the controls and their values with casts such as: if (Emp_Form.CurrentMode == FormViewMode.Insert)
CheckBox active = (CheckBox)Emp_Form.FindControl("cbActive");
But when the FormView is in Edit there aren't and controls during the (partial) post back. A reference to them such as: if (Emp_Form.CurrentMode == FormViewMode.Edit)
TextBox usrNmTB = (TextBox)Emp_Form.FindControl("UserNmTbx");
sUsr = usrNmTB.Text.ToString();
results in a Null object reference exception.
When a button's onclick runat server event fires how should I capture the FormView's controls collection? Why does it work for the Insert mode and not the Edit mode?
Thanks in adva
View Complete Post