title: How to remove appended items from DropDownlist on postback in ASP.NET and C#
body: <p>I have two <code>DropDownList</code> controls in cascade (the second one is populated based on the selection made on the first one):</p>
  
  <pre><code>&lt;asp:DropDownList ID="ddlProduct" runat="server" AppendDataBoundItems="true" 
      AutoPostBack="true" onselectedindexchanged="ddlProduct_SelectedIndexChanged"&gt;
      &lt;asp:ListItem Value="" Selected="True"&gt; - Product - &lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  
  &lt;asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="true" 
      OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged" AppendDataBoundItems="true"&gt;
      &lt;asp:ListItem Value="" Selected="True"&gt; - Category - &lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>In the <code>ddlProduct.SelectedIndexChanged</code> event handler I have the following code:</p>
  
  <pre><code>ddlCategory.DataSource = _productService.GetCategoryByProductId(ddlProduct.SelectedValue);
  ddlCategory.DataTextField = "CategoryName";
  ddlCategory.DataValueField = "CategoryId";
  ddlCategory.DataBind();
  </code></pre>
  
  <p>The first time a user choose a Product from <code>ddlProduct</code> the <code>ddlCategory</code> is populated correctly. The following times, the Categories in <code>ddlCategory</code> are appended to those that were selected the first time and so on. I tried to put in <code>ddlProduct.SelectedIndexChanged</code>:</p>
  
  <pre><code>ddlCategory.Items.Clear();
  </code></pre>
  
  <p>but the method removes also the hardcoded item </p>
  
  <pre><code>&lt;asp:ListItem Value="" Selected="True"&gt; - Category - &lt;/asp:ListItem&gt;
  </code></pre>
  
  <p>How can I just delete the appended item from ddlCategory?</p>