数据源如下:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Type> List = new List<Type>();
for (int i = 0; i <= 5; i++)
{
Info inf = new Info();
inf.title = i.ToString() + "标题";
inf.url = i.ToString() + "地址";
List<Info> lis = new List<Info>();
for (int j = 0; j <= 3; j++) {
lis.Add(inf);
}
List.Add(new Type { id = i.ToString(), Name = i.ToString(), info = lis });
}
Repeater1.DataSource = List;
Repeater1.DataBind();
}
}
public class Type
{
public string id { get; set; }
public string Name { get; set; }
public List<Info> info { get; set; }
}
public class Info
{
public string title { get; set; }
public string url { get; set; }
}
前台如何绑定 Info
实现info 的循环。
<asp:repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#Eval("id")%><br />
<%#Eval("Name")%><br />
<%#Eval("Info") as System.Collections.Generic.List<Web.Info>%>
<br />
</ItemTemplate>
</asp:repeater>
用得着这么绕吗?你这样我没试过
要是实在不行就用StringBuilder自己拼吧 还比较好控制
Repeater嵌套...