title: No Change for Index of DropDownList in a Custom Control!
body: <p>I have Created A Custom Control which is a DropDownList with specified Items. I designed <code>AutoPostback</code> and <code>SelectedCategoryId</code> as Properties and <code>SelectedIndexChanged</code> as Event for My Custom Control.<br/>
   Here Is My ASCX file Behind Code:<br/></p>
  
  <pre><code>private int _selectedCategoryId;
  
  private bool _autoPostback = false;
  
  public event EventHandler SelectedIndexChanged;
  
  public void BindData()
  {
      //Some Code...
  }
  
  protected void Page_Load(object sender, EventArgs e)
  {
      BindData();
      DropDownList1.AutoPostBack = this._autoPostback;
  }
  
  public int SelectedCategoryId
  {
      get
      {
          return int.Parse(this.DropDownList1.SelectedItem.Value);
      }
      set
      {
          this._selectedCategoryId = value;
      }
  }
  
  public string AutoPostback
  {
      get
      {
          return this.DropDownList1.AutoPostBack.ToString();
      }
      set
      {
          this._autoPostback = Convert.ToBoolean(value);
      }
  }
  
  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      if (SelectedIndexChanged != null)
          SelectedIndexChanged(this, EventArgs.Empty);
  }
  </code></pre>
  
  <p>I Want Used Update Panel to Update Textbox Fields According to dorp down list selected index.<br/>
  this is my code in ASPX page:<br/></p>
  
  <pre><code>&lt;asp:Panel ID="PanelCategory" runat="server"&gt;
      &lt;p&gt;
          Select Product Category:&amp;nbsp;
          &lt;myCtrl:CategoryDDL ID="CategoryDDL1" AutoPostback="true" OnSelectedIndexChanged="CategoryIndexChanged"
              SelectedCategoryId="0" runat="server" /&gt;
      &lt;/p&gt;
      &lt;hr /&gt;
  &lt;/asp:Panel&gt;
  &lt;asp:UpdatePanel ID="UpdatePanelEdit" runat="server"&gt;
      &lt;ContentTemplate&gt;
          &lt;%--Some TextBoxes and Other Controls--%&gt;
      &lt;/ContentTemplate&gt;
      &lt;Triggers&gt;
          &lt;asp:PostBackTrigger ControlID="CategoryDDL1" /&gt;
      &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>But Always The Selected Index of CategoryDDL1 is 0(Like default). this means Only Zero Value will pass to the event to update textboxes Data. what is the wrong with my code? why the selected Index not Changing? Help?</p>