Repeater1_ItemDataBound事件里绑定子Repeater
Repeater1_ItemDataBound事件里绑定子Repeater报 "Repeater2
未将对象引用设置到对象的实例。 "
------解决方案--------------------http://www.cnblogs.com/ilovejolly/archive/2006/10/17/527593.html
------解决方案--------------------楼上为何不用BAIDU?
------解决方案-------------------- 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 ");
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();
}
}
------解决方案--------------------呵呵,发的是三层嵌套
如果是两层
看这里就够了:
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();
}
}