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的哪個(gè)位置(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對(duì)象
datarowview row = (datarowview)e.item.dataitem; //找到分類repeater關(guān)聯(lián)的數(shù)據(jù)項(xiàng)
int typeid = convert.toint32(row["id"]); //獲取填充子類的id
rpt.datasource = datatable;
rpt.databind();
}
}