两层嵌套
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rpt = (Repeater)e.Item.FindContro( "rpt_Level04 ");
int typeFatherID = ((CommonType)e.Item.DataItem).TypeID;
rpt.DataSource = da.GetAllNodeInfo(tt, typeFatherID);
rpt.DataBind();
}
}
三层嵌套
protected void rpt_Level02_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem)
{
Repeater rpt = (Repeater)e.Item.FindControl( "rpt_Level03 ");
//给下一层repeater绑定事件
rpt.ItemDataBound += new RepeaterItemEventHandler(rpt_ItemDataBound);// <==这里是关键
int typeFatherID = ((CommonType)e.Item.DataItem).TypeID;
rpt.DataSource = da.GetAllNodeInfo(tt, typeFatherID);
rpt.DataBind();
}
}
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rpt = (Repeater)e.Item.FindControl( "rpt_Level04 ");
int typeFatherID = ((CommonType)e.Item.DataItem).TypeID;
rpt.DataSource = da.GetAllNodeInfo(tt, typeFatherID);
rpt.DataBind();
}
}