title: Dropdown binding and postbacks - ASP.NET
body: <p>I have a rather complex page. The ASPX page loads a user control which in turn loads a child User control.</p>
  
  <p>Parent Control</p>
  
  <pre><code>protected override void OnInit(EventArgs e)
  {
    //Loads child control
  }
  </code></pre>
  
  <p>In the child user control, I use custom control that inherits from <code>System.Web.UI.HtmlControls.HtmlSelect</code></p>
  
  <p>ASCX:</p>
  
  <pre><code>&lt;cust:CustDropDownList id="ctlDdl" runat="server"/&gt;
  </code></pre>
  
  <p>ASCX.CS</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
    //Binds CtlDdl here 
  }
  </code></pre>
  
  <p>When the user clicks on the Save button, the controls get user controls get dynamically reloaded, but Iose the value the user has selected in the dropdown. I run into the chicken and egg problem here.</p>
  
  <p>I think I need to bind the ctlDdl only on if its not a postback, but that results in the dropdown not getting populated.</p>
  
  <p>If I bind it everytime, then i lose user's selection</p>
  
  <p><strong>EDIT:
  Can someone respond to my comment to Jonathan's answer? Thanks</strong></p>