title: Not possible to load DropDownList on FormView from code behind?
body: <p>I have a UserControl, containing a FormView, containing a DropDownList.
  The FormView is bound to a data control.</p>
  
  <p>Like so:</p>
  
  <pre><code>&lt;asp:FormView ID="frmEdit" DataKeyNames="MetricCode" runat="server" DefaultMode="Edit" DataSourceID="llbDataSource" Cellpadding="0" &gt;
      &lt;EditItemTemplate&gt;
          &lt;asp:DropDownList ID="ParentMetricCode"  runat="server" SelectedValue='&lt;%# Bind("ParentMetricCode") %&gt;' /&gt;
      &lt;/EditItemTemplate&gt;
  &lt;asp:FormView&gt;
  </code></pre>
  
  <p>I am trying to populate the DropDownList from the codebehind.  If this was not contained in a FormView, I would normally just do it in the Page_Load event.  However, that does not work within a FormView, as as soon as I try to do it, accessing the dropdownlist in code, i.e.:</p>
  
  <pre><code>theListcontrol = CType(formView.FindControl(listControlName), ListControl)  
  </code></pre>
  
  <p>...the data binding mechanism of the FormView is invoked, which, of course, tries to bind the DropDownList to the underlying datasource, causing a **'ParentMetricCode' has a SelectedValue which is invalid because it does not exist in the list of items. "Parameter name: value ..." error, since the DropDownList has not yet been populated.</p>
  
  <p>I tried performing the load in the DataBinding() event of the FormView, but then:</p>
  
  <pre><code>theListcontrol = CType(formView.FindControl(listControlName), System.Web.UI.WebControls.ListControl)
  </code></pre>
  
  <p>...fails, as the FormView.Controls.Count = 0 at that point.</p>
  
  <p>Is this impossible?  (I do not want to have to use a secondary ObjectDataSource to bind the dropdownlist to)</p>