第1种方法:
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<%#(Container.ItemIndex) % 5 == 0 ? "<ul>" : String.Empty%>
<li>abc</li>
<%#(Container.ItemIndex) % 5 == 4 ? "</ul>" : String.Empty%>
</ItemTemplate>
</asp:Repeater>
第2种方法:
<asp:Repeater ID="Repeater2" runat="server"
onitemdatabound="Repeater2_ItemDataBound">
<ItemTemplate>
<asp:Literal ID="HeadLiteral" runat="server"></asp:Literal>
<li>abc</li>
<asp:Literal ID="FooterLiteral" runat="server"></asp:Literal>
</ItemTemplate>
</asp:Repeater>
-----------------------------------------------------------------------------------------------------------
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemIndex % 5 == 0)
{
Literal HeadLiteral = (Literal)e.Item.FindControl("HeadLiteral");
HeadLiteral.Text = "<ul>";
}
if (e.Item.ItemIndex % 5 == 4)
{
Literal FooterLiteral = (Literal)e.Item.FindControl("FooterLiteral");
FooterLiteral.Text = "</ul>";
}
}