title: ASP.NET DropDownList.SelectedValue has not value on PostBack with dynamic data-binding
body: <p><strong>Setup</strong><br>
  Using: Visual Web Developer 2010 Express.<br>
  Language: C#.<br>
  Target Framework: .NET Framework 4.<br>
  ViewState: I have disabled ViewState in the Web.Config - i.e.   <code>&lt;configuration&gt;&lt;system.web&gt;&lt;pages enableViewState="false" /&gt;</code>.</p>
  
  <p><strong>Problem</strong><br>
  I have an ASP.NET page with a standard DropDownList control.<br>
  I have set EnableViewState="true" and ViewStateMode="Enabled" on the DropDownList.<br>
  I'm using data binding in the code-behind to populate the control (this works fine).<br>
  Data binding happens in a call from Page_PreRender, on both initial load and post-back.<br>
  In a call from a Button Click event handler (i.e. before the Page_PreRender) I am trying to read from the SelectedValue property of the DropDownList.<br>
  The problem is: all I ever receive is a zero-length-string ("") value and inspection of the object indicates the control contains to values.  </p>
  
  <p><strong>Solution</strong><br>
  Ensure EnableViewState="true" is set within the &lt;%@ Page %> directive on the page containing the DropDownList.  </p>
  
  <p>Alternatively, you could create an extension method for the DropDownList that reads the value from the HttpRequest collection.<br>
  e.g.</p>
  
  <pre><code>public static string GetSelectedValue(this System.Web.UI.WebControls.DropDownList listBox)
  {
    return HttpContext.Current.Request[listBox.ClientID];
  }
  </code></pre>