Repeater中能不能嵌套一个Repeater做循环
不知道Repeater中能不能嵌套一个Repeater做循环,我想做个动态的3级导航,一级导航在头部,然后点头部的导航链接之后,可以进入内容页在左边动态的显示2级导航,然后在2级导航下面显示3级导航!不知道可以不可以实现!
------解决方案--------------------可以。。
repeater嵌套菜单
2级 3级 N级同理
------解决方案--------------------可以的
前台[code=C#][/code]<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
<div><li class="first">
<strong style=" line-height:30px"> <%# DataBinder.Eval(Container.DataItem, "MainSort")%></strong></b>
<asp:Repeater runat="server" ID="repeater2">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate><li style="border-top:0;" ><a href="<%# GetFourTitle("Product.aspx?id="+Eval("ID"))%>"><%# DataBinder.Eval(Container.DataItem, "Name")%></a></li></ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater> </li>
</div>
</ItemTemplate>
</asp:Repeater>
后台
this.repeater1.ItemDataBound += new RepeaterItemEventHandler(repeater1_ItemDataBound);
private void repeater1_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
Repeater repater2 = (Repeater)e.Item.FindControl("repeater2");
ProductSort rowv = (ProductSort)e.Item.DataItem;
int id = Convert.ToInt32(rowv.Id);
ProductSystem ps = new ProductSystem();
List<BusinessEntities.Product> listp = ps.GetAll(id);
List<BusinessEntities.Product> listcopy = new List<BusinessEntities.Product> ();
BusinessEntities.Product pt;
for (int i = 0; i < listp.Count; i++)
{
pt = new BusinessEntities.Product();
pt = listp[i];
MainSortSystem ms = new MainSortSystem();
Int32 _sortid = Int32.Parse(pt.SortID.ToString());
ProductSort pds = ms.GetModel(_sortid);
int j = pds.MainSort.IndexOf(" ");
pt.ImagUrl = "/products/" + pds.MainSort.Substring(0, j) + "/" + pt.Name.Replace(" ", "-");
listcopy.Add(pt);
}
repater2.DataSource = listcopy;
repater2.DataBind();
}
------解决方案-------------------- 学习了
------解决方案--------------------可以的,不过那么多层会很烦。。绑定数据比较繁琐