title: Custom user control data source
body: <p>I have a custom control that has a DropDownList inside and it's created by CreateUserControl. I'm saving data source directly to dropdown control. After page postbacked my binded data disappear. Should i save/restore my binded data myself in some tricky way?</p>
  
  <pre><code>public class EnumDropDownList : UserControl
  {
      private readonly DropDownList _ddlSelector;
      private Dictionary&lt;long, string&gt; _dataSource;
  
      public EnumDropDownList()
      {
          _ddlSelector = new DropDownList();
          _dataSource = new Dictionary&lt;long, string&gt;();
      }
  
  
      public object DataSource
      {
          set
          {
              // datasource logic
          }
      }
  
      public long SelectedValue
      {
          get { return Convert.ToInt64(_ddlSelector.SelectedValue); }
          set { _ddlSelector.SelectedValue = value.ToString(); }
      }
  
      public override void DataBind()
      {
          _ddlSelector.DataSource = _dataSource;
          _ddlSelector.DataTextField = "Value";
          _ddlSelector.DataValueField = "Key";
          _ddlSelector.DataBind();
  
          base.DataBind();
      }
  
      [PermissionSet(SecurityAction.Demand, Name = "Execution")]
      protected override void CreateChildControls()
      {
          Controls.Add(_ddlSelector);
      }
  }
  </code></pre>