如何绑定子repeater的值(嵌套repeater)
现在有repeater1,里面嵌套了repeater2,分别都绑有数据,repeater2只有一行数据,由于排版原因,现要在repeater1里面,在repeater2外面绑定repeater2的值,可以实现吗?不能实现的话,用什么方法可以实现这种效果?Thank You!!!
------解决方案--------------------在母repeater的item_databound事件中,设置子repeater的datasource 进行绑定就是了.
------解决方案--------------------父Repeater : repMag 中:
private void repMag_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Label lb = (Label)e.Item.FindControl( "labMagID ");
int magID = Convert.ToInt32(lb.Text);
//子Repeater :subrepMag
Repeater rep = (Repeater)e.Item.FindControl( "subrepMag ");
//rep.ItemDataBound +=new RepeaterItemEventHandler(rep_ItemDataBound);
Components.Magazines cp = new ezcom.Components.Magazines();
DataSet ds = cp.GetMagRemark(magID);
if (ds.Tables[0].Rows.Count> 0)
{
rep.DataSource = ds;
rep.DataBind();
}
}
}