.net Repeater嵌套的数据绑定问题
<asp:Repeater ID="Repeater3" runat="server" OnItemDataBound="Repeater3_ItemDataBound">
<ItemTemplate>
bind(Data)//绑定的数据
<asp:Repeater ID="Repeater4" runat="server">
<ItemTemplate>
bind(Data)//绑定的数据
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
后台Repeater4的绑定
/// <summary> ///数据绑定 ///绑定回复 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Repeater3_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rpt1 = e.Item.FindControl("Repeater4") as Repeater; if (rpt1 != null) { Repeater rep = (Repeater)e.Item.FindControl("Repeater4"); DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 int typeid = Convert.ToInt32(rowv["id"]); //获取填充子类的id StringBuilder sb = new StringBuilder("select 语句 "); sb.Append(" where 条件(用到typeid )“); DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sb.ToString()); rep.DataSource = ds; rep.DataBind(); } } }
天再高,踮起脚尖就能更接近阳光