获取repeater嵌套子repeater的控件
protected void gv_list_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Repeater rp_list = (Repeater)e.Item.FindControl("rp_list");
rp_list.ItemDataBound += new RepeaterItemEventHandler(rp_list_ItemDataBound);
DataSet ds = baseinfo.BindInfo("表名", "");
rp_list.DataSource = ds.Tables[0].DefaultView;
rp_list.DataBind();
}
}
//子repeater绑定事件
protected void rp_list_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
//如何获取子repeater中的控件
//Repeater rp_list = (Repeater)e.Item.FindControl("rp_list");
//DataView dv = (DataView)rp_list.DataSource;
//Label lb_cg = (Label)rp_list.Controls[rp_list.Controls.Count - 1].FindControl("lb_cg");
//lb_cg.Text = cg.ToString();
}
}
控件
------解决方案--------------------rp_list_ItemDataBound中用FindControl
------解决方案--------------------这样呢
Label lb_cg= (Label)e.Item.FindControl("lb_cg");