发布网友 发布时间:2022-04-27 12:12
共2个回答
懂视网 时间:2022-04-27 16:33
前台代码部分:
代码如下:
<asp:repeater runat="server" id="repeater1" OnItemDataBound="function2">
<itemtemplate>
<asp:repeater runat="server" id="repeater2">
<itemtemplate>
</itemtemplate>
</asp:repeater>
<itemtemplate>
</asp:repeater>
后台代码部分:
代码如下:
private void function1()
{
repeater1.datasource = datatable;
repeater1.databind();
}
private void function2(object sender,repeateritemeventargs e)
{
//判断里层repeater处于外层repeater的哪个位置(alternatingitemtemplate,footertemplate,headertemplate,itemtemplate,separatortemplate)
if(e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem)
{
repeater rpt = e.item.findcotrol("repeater2") as repeater; //找到里层的repeater对象
datarowview row = (datarowview)e.item.dataitem; //找到分类repeater关联的数据项
int typeid = convert.toint32(row["id"]); //获取填充子类的id
rpt.datasource = datatable;
rpt.databind();
}
}
热心网友 时间:2022-04-27 13:41
给你个例子: http://www.w3.org/1999/xhtml" > Repeater菜单导航 <!-- function showMenu(id) { var menu=document.getElementById("Menu"+id); var item=document.getElementById("Item"+id); if(item.style.display=="none") { item.style.display="block"; menu.style.backgroundImage="url(images/menuup.gif)"; } else { item.style.display="none"; menu.style.backgroundImage="url(images/menudown.gif)"; } } //--> <%# Eval("KindName") %> <%# Eval("CourseName") %>