How can I populate a bootstrap dropdown from codebehind? Right now I am trying this:
HtmlGenericControl li;
for (int x = 3; x <= 10; x++)
{
li = new HtmlGenericControl("li");
li.Attributes.Add("class", "myItemClass");
li.InnerText = "Item " + x;
myList.Controls.Add(li);
}
This does add the items but it completely loses the bootstrap design on the <li>-items. Also, how do I know which value is DataTextField and which is DataValueField?
Dropdown html:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" id="myList" runat="server">
</ul>
</div>
<li>items, whereas they are using<li><a/></li><li><a/></li>itemsli.Children.Add(new GenericControl("a"));