<p>I'm dynamically generating an asp form, and I would like to add the <strong>label</strong> and <strong>input</strong> elements inside a list.</p>

<p>For example, I would like to end up with something like:</p>

<pre><code>&lt;ul&gt;
&lt;li&gt;&lt;label for="input"/&gt;&lt;input id=input"/&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>To do this, I create a Label object and a TextBox object, then assign the AssociatedControlId property of the Label to link these. But I cannot add any of these in a ListItem, nor can I add these in the Controls collection of BulletedList...</p>

<p>Any ideas would be greatly apreciated.</p>

You could probably do something like this using a Repeater.
```
```
<asp:Repeater ID="rpt" runat="server">
    <HeaderTemplate>
        <ul>
    </HeaderTemplate>
    <ItemTemplate>
        <li>
            <label for='<%# string.Format("ctrl-{0}", Container.ItemIndex) %>'>label for ctrl #<%# Container.ItemIndex %></label>
            <input id='<%# string.Format("ctrl-{0}", Container.ItemIndex) %>' type="text" />                
        </li>
    </ItemTemplate>
    <FooterTemplate>
        </ul>
    </FooterTemplate>
</asp:Repeater>
```
```
If you need to add server controls to the list, you'll need to do something with the Repeater's ItemDataBound event.