Pom*_*ter 0 c# asp.net webforms list
我有一个C#列表:
List<string> Listtags = GetListTag.GetTagList().ToList();
Run Code Online (Sandbox Code Playgroud)
而且,我想把它变成一个Div:
<div id="tags">
<ul>
<li><This should be populated with my list></li>
//This list can have any number of items depending on how big my list tags is
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
有人能告诉我怎么做吗?
你也可以使用Repeater
<ul>
<asp:Repeater runat="server" id="R">
<ItemTemplate>
<li><%# Container.DataItem %></li>
</ItemTemplate>
</asp:Repeater>
</ul>
Run Code Online (Sandbox Code Playgroud)
并在运行时
List<string> ListTags = GetListTag.GetTagList().ToList();
R.DataSource = ListTags;
R.DataBind();
Run Code Online (Sandbox Code Playgroud)