title: Why is this DropDownList data binding to a List<String> not working?
body: <p>I'm trying to bind a <code>List&lt;String&gt;</code> to a <code>DropDownList</code> in a user control. I <em>think</em> I'm doing the right thing, but it seems that after my code executes the <strong>bindings are cleared</strong>. Here's the code for review!</p>
  
  <p><strong>User control:</strong></p>
  
  <pre><code>&lt;asp:DropDownList ID="subjectNameDropDown" runat="server"/&gt;
  &lt;asp:DropDownList ID="yearLevelDropDown" runat="server"/&gt;
  </code></pre>
  
  <p><strong>Auto-generated designed code-behind:</strong></p>
  
  <pre><code>public partial class NewSiteMetadataUserControl {
      protected global::System.Web.UI.WebControls.DropDownList subjectNameDropDown;
      protected global::System.Web.UI.WebControls.DropDownList yearLevelDropDown;
  }
  </code></pre>
  
  <p><strong>Code-behind:</strong></p>
  
  <pre><code>public partial class NewSiteMetadataUserControl : UserControl
  {
      protected override void CreateChildControls()
      {
          subjectNameDropDown = new DropDownList();
          yearLevelDropDown = new DropDownList();
      }
  
      protected override void OnLoad(EventArgs e)
      {
          base.OnLoad(e);
          EnsureChildControls();
  
          // Attempt 1
          List&lt;String&gt; subjectNames = GetSubjectValues();
          foreach (var subjectName in subjectNames)
              subjectNameDropDown.Items.Add(subjectName);
          subjectNameDropDown.DataBind();
  
          // Attempt 2
          List&lt;String&gt; yearLevels = GetYearLevelValues();
          yearLevelDropDown.DataSource = yearLevels;
          yearLevelDropDown.DataBind();
      }
  }
  </code></pre>
  
  <p><em>Should this approach work?</em></p>
  
  <p>If it should, <em>how can I debug what happens after the code executes?</em></p>