In some special cases it is necessary to use repeater in Repeater, here is a good example, interested friends can refer to the following
The code is as follows: protected void Page_Load (object sender, EventArgs e) { if (! Page.IsPostBack) { this.dtcategory = getcategorytable (); this.dtproduct = getproducttable (); Rptcategorylist.datasource = dtcategory; rptcategorylist.databind (); } } //Prepare a list DataTable getcategorytable () { datatable dt = new DataTable (); dt. Columns.Add ("CategoryID", typeof (int)); dt. Columns.Add ("Categorytitle", typeof (String)); for (int i = 1; I <= 3; i++) { DataRow row = dt. NewRow (); row["CategoryID"] = i; row["categorytitle"] = "Classification name" + i + ""; dt. Rows.Add (Row); } return dt; } //Prepare a product table DataTable getproducttable () { DataTable dt = new DataTable (); dt. Columns.Add ("ProductTitle", typeof (String)); dt. Columns.Add ("CategoryID", typeof (int)); for (int i = 1; I <= 9; i++) { DataRow row = dt. NewRow (); row["ProducttiTle "] =" Product Name "+ i +" "; if (i > 6) row[" CategoryID "] = 3; else if (i > 3) row[" CategoryID "] = 2; else row["CategoryID"] = 1; dt. Rows.Add (Row); } return dt; } //Get a category of products DataTable getproducttable (int CategoryID) { DataView dv = this.dtproduct.defaultview; dv. RowFilter = "Categoryid=" + CategoryID + ""; return DV. ToTable (); } protected void Rptcategorylist_itemdatabound (object sender, RepeaterItemEventArgs e) {& nbsp if (E.item.itemtype = = ListItemType.AlternatingItem | | e.item.itemtype = listitemtype.item) { DataRowView DRV = (DataRowView) e.item.dataitem; Literal ltltitle = (Literal) e.item.findcontrol ("Ltltitle"); Ltltitle.text = drv["Categorytitle"]. ToString (); Repeater rptproductlist = (Repeater) e.item.findcontrol ("Rptproductlist"); Rptproductlist.datasource = getproducttable (Convert.ToInt32 (drv["CategoryID")); RptProductList.DataBind (); } } protected void Rptproductlist_itemdatabound (object sender, RepeaterItemEventArgs e) {& nbsp if (E.item.itemtype = = ListItemType.AlternatingItem | | e.item.itemtype = listitemtype.item) { DataRowView DRV = (DataRowView) e.item.dataitem; Literal ltltitle = (Literal) e.item.findcontrol ("Ltltitle"); Ltltitle.text = drv["ProductTitle"]. ToString (); } } foreground aspx code code is as follows: <</code>form id= "Form1" runat= "Server" > <</CODE>div> <</code>asp:repeater id= "rptcategorylist" runat= "Server" Onitemdatabound= "Rptcategorylist_itemdatabound" > <</CODE>ItemTemplate> <</code >div class= "ListBox" > <</code>div class= "title" > <</code>asp:literal id= " Ltltitle "runat=" Server ></</CODE>asp:Literal></</CODE>div> <</CODE> div class= "Content" > <</CODE>ul> <</code>asp:repeater id= "rptproductlist" runat= "Server" onitemdatabound= "Rptproductlist_itemdatabound" > <</CODE>ItemTemplate> <</CODE>li> <</code>asp:literal id= " Ltltitle "runat=" Server ></</CODE>asp:Literal> </</CODE>li> </</code >ItemTemplate> </</CODE>asp:Repeater> </</CODE>ul> </</code >div> </</CODE>div> </</CODE>ItemTemplate> </</code>asp: repeat</</code>div> </</CODE>form>