title: ASP.Net: drop down list and data source created dynamically
body: <p>I have about 10 drop down list controls that get populated. Instead of copying/pasting and modifying a few fields on each, I would like to create them programmatically. Can this be done? </p>
  
  <p>Here is what one of them looks like. I would like to programmatically add 10 dropdownlist controls and their respective SqlDataSource controls. </p>
  
  <pre><code>   &lt;asp:SqlDataSource ID = "ddlDAGender" runat=server
      ConnectionString="&lt;%$ ConnectionStrings:test1ConnectionString %&gt;" 
      SelectCommand = "select GenderID,Gender from mylookupGender"
      &gt;
      &lt;/asp:SqlDataSource&gt;
  
  
   &lt;asp:Label ID="Label3" runat="server" Text="Gender"&gt;&lt;/asp:Label&gt;
  
          &lt;asp:DropDownList ID="ddlGender" runat="server" 
                  DataSourceid="ddlDAGender"
                  DataTextField="Gender" DataValueField="GenderID"
  
      &gt;
  
   &lt;/asp:DropDownList&gt;
  </code></pre>