不是嵌套Repeater拿Repeater另外一个隐藏

2024-12-27 09:49:05
推荐回答(1个)
回答1:

protectedvoid rptMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rpt = e.Item.FindControl("rptSonMenu") as Repeater;//找到里层的repeater对象
rpt.ItemDataBound+=new RepeaterItemEventHandler(rpt_ItemDataBound);
rpt.ItemCommand += new RepeaterCommandEventHandler(rpt_ItemCommand);
DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 int ID = Convert.ToInt32(rowv["ID"]); //获取填充子类的id
rpt.DataSource = meBLL.SelectSonMenu(ID);
rpt.DataBind();
}
}

其实就是 Repeater 嵌套 ,内层Repeater 数据绑定是 获取上层 的数据