Repeater three-level nested binding,
<Asp: repeater ID = "rpt1" runat = "server" onitemdatabound = "rpt1_ItemDataBound"> <HeaderTemplate> <table width = 400 cellpadding = 0 cellspacing = 0> </HeaderTemplate> <ItemTemplate> <tr> <td> <font color = black> background. Aspx. cs
Protected void rpt1_ItemDataBound (object sender, RepeaterItemEventArgs e) {if (e. item. itemType = ListItemType. item | e. item. itemType = ListItemType. alternatingItem) {Repeater rpt2 = (Repeater) e. item. findControl ("rpt2"); // find the data item associated with the category Repeater DataRowView rowv = (DataRowView) e. item. dataItem; rpt2.ItemDataBound + = new RepeaterItemEventHandler (rpt2_ItemDataBound); // The most important sentence // extract classification ID cid = Convert. toInt32 (rowv ["ID"]); // query the products under this category based on the category ID, and bind the product Repeater rpt2.DataSource = Pcategory. getP (cid); // data binding rpt2.DataBind () ;}} protected void rpt2_ItemDataBound (object sender, RepeaterItemEventArgs e) {if (e. item. itemType = ListItemType. item | e. item. itemType = ListItemType. alternatingItem) {Repeater rpt3 = (Repeater) e. item. findControl ("rpt3"); // locate the data item associated with the category Repeater, DataRowView rowvv = (DataRowView) e. item. dataItem; // extract the category ID cid2 = Convert. toInt32 (rowvv ["ID"]); // query the products under this category based on the category ID, and bind the product Repeater rpt3.DataSource = getrpt3 (cid, cid2 ); // data binding rpt3.DataBind ();}}
Reprinted from: http://www.aspnetjia.com