Repeater nesting in Asp.net (ilist)

Source: Internet
Author: User

There is an ilist generic class for a commodity order. Now I want to present all the commodity orders,
Ilist <order> orderlist = new list <order> (); // Declaration
Orderlist = getorderlist (); // obtain the order list
Repeater. datasource = orderlist; // bind to the Repeater control

However, there is a member in the orderlist class, orderlist. productlist. This member variable is of the ilist type and refers to the product list in the order, that is, there are multiple products in a product order.
Now I want to display them with nested repeater. Let's give a method.

As follows:

Order 1

User name: xx
Shipping address: xx
Product list:
Product 1
Product 2
......

Order 2

User name: xx
Shipping address: xx
Product list:
Product 1
Product 2
......

 

 

 

 

Use the itemdatabound event of Repeater
------------------------------
Aspx

<Asp: repeater id = "Repeater" runat = "server" onitemdatabound = "repeater_itemdatabound">
<Itemtemplate>
<Asp: repeater id = "child" runat = "server">
<Itemtemplate>
.....
</Itemtemplate>
</ASP: repeater>
</Itemtemplate>
</ASP: repeater>

---------------------------
Aspx. CS
Protected void repeater_itemdatabound (Object sender, repeateritemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
Ilist <order> orderlist = (ilist <order>) Repeater. datasource;
Repeater rep = (repeater) E. Item. findcontrol ("child ");
Rep. datasource =
Orderlist. productlist;
Rep. databind ();
}
}

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.