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 ();
}
}