Repeater three-level nested binding,

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.