asp.net - Problem finding a control within a FormView from code-behind -


The code behind here ... I am trying to regain this control so that I am in the drop down list Add item (I am retrieving the code-back to add to the drop-down list in the role group)

  Protected Sub Page_Load (ByVal, as in this System.Object, ByVal e System. EventArgs handles MyBase .load dim DDRoleGroups DropDownList DDRoleGroups = FormView1.FindControl ("DDRoleGroup") as End Sub   

Here is the FormView: (I Es took most so it's easier to read)

  & lt; ASP: FormView ID = "FormView1" runat = "server" DataKeyNames = "id" DataSourceID = "ObjectDataSource_Vendors" DefaultMode = "Insert" BorderColor = "DarkGray" BorderStyle = "solid" Borderwyuth = "1 px" cellpadding = "4" visible = "Wrong" & gt; & Lt; EditItemTemplate & gt; & Lt; / EditItemTemplate & gt; & Lt; InsertItemTemplate & gt; & Lt; Label class = "form_label" & gt; Role Group: & lt; / Labels & gt; & Lt; Br / & gt; & Lt; ASP: DropDownList ID = "DDRoleGroup" runat = "server" width = "175px" EnableViewState = "false" & gt; & Lt; / ASP: DropDownList & gt; & Lt; / InsertItemTemplate & gt; & Lt; / ASP: FormView & gt;  

Is this probably the fact that this Page_Load is in sub and control is not loaded acctually yet?

Thanks, Matt
What to do with

Your do dropdown only exists in insert mode trying to implement ModeChanged event FormView control is retrieved, then CurrentMode insert ==:

  protected void FormView1_ModeChanged (object sender, EventArgs e ) {if (FormView1.CurrentMode == FormViewMode.Insert) {dropdown list DDRoleGroups = FormView1.FindControl ( "DDRoleGroup"); // fill dropdown}}  

You can not handle it in page_load, because the form is not currently running in the Insert mode.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -