Binding a Dropdown inside repeater
<p>I'm binding a <code>DropDownList</code> inside a repeater and below is my mark up</p>



<pre class="lang-xml prettyprint-override"><code> &lt;asp:Repeater ID="Repeater2" runat="server" 
    onitemdatabound="Repeater2_ItemDataBound"&gt;
      &lt;HeaderTemplate&gt;
     &lt;asp:DropDownList ID="DropDownList8" runat="server"&gt;
    &lt;asp:ListItem&gt;Select&lt;/asp:ListItem&gt;
    &lt;asp:ListItem&gt;Left&lt;/asp:ListItem&gt;
    &lt;asp:ListItem&gt;Right&lt;/asp:ListItem&gt;
    &lt;asp:ListItem&gt;SubString&lt;/asp:ListItem&gt;
   &lt;/asp:DropDownList&gt;
   &lt;asp:DropDownList ID="DropDownList7" runat="server"&gt;
 &lt;asp:ListItem&gt;1&lt;/asp:ListItem&gt;
   &lt;asp:ListItem&gt;2&lt;/asp:ListItem&gt;
   &lt;asp:ListItem&gt;3&lt;/asp:ListItem&gt;
   &lt;/asp:DropDownList&gt;
   &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt;
   &lt;/asp:DropDownList&gt;
   &lt;asp:DropDownList ID="DropDownList2" runat="server"&gt;
   &lt;/asp:DropDownList&gt;
   &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;

   &lt;/HeaderTemplate&gt;

  &lt;FooterTemplate&gt;
  &lt;br /&gt;
   &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
 &lt;/FooterTemplate&gt;
  &lt;/asp:Repeater&gt;
</code></pre>

<p> </p>



<pre class="lang-cs prettyprint-override"><code>protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
  try
  {

      if (e.Item.ItemType == ListItemType.Header)
      {

          DataTable dt = new DataTable();
          dt = Common.LoadExample();

          DropDownList ddl = (DropDownList)e.Item.FindControl("DropDownList2");
          ddl.DataSource = dt;
          ddl.DataTextField = "Name";
          ddl.DataValueField = "Name";

      }
  }
  catch (Exception ex)
  {
      throw;

  }
}
</code></pre>

<p>but I'm unable to fill the dropdown list as the breakpoint is skipping <code>e.Item.ItemType == ListItemType.Header</code> here. How can I solve this?</p>
