如何从代码隐藏填充 UL

How to populate UL from code-behind

我的 ASP.net 页面中有一个 UL

<ul id="ulO" runat="server">
</ul>

代码隐藏:

foreach (string wrWG in workGroupLists)
{
    // add each "wrWG" as a list item to the `ulO`
}

我尝试使用 asp:Repeater 进行填充,但没有用。

这会起作用:

foreach (string wrWG in workGroupLists)
{
  HtmlGenericControl li = new HtmlGenericControl("li");
  li.InnerText = wrWG; 
  ulO.Controls.Add(li);
}