Repeater nested binding

Source: Internet
Author: User

Front-end code:

<Div id = "firstpane" class = "menu_list">
<Asp: repeater id = "rep1" runat = "server" onitemdatabound = "rep1_itemdatabound">
<Itemtemplate>
<P class = "menu_head" id = "P <% # eval (" p_typeid ") %>"> <% # eval ("type_name") %> </P>
<Div class = "menu_body" id = "Div <% # eval (" p_typeid ") %>">

<Asp: repeater id = "rep2" runat = "server">
<Itemtemplate>
<A id = "A <% # eval (" p_typeid ") %>" href = "media. aspx? Types = <% # eval ("p_typeid") %> & ptypeid = <% # eval ("p_typepid") %> ">
<% # Eval ("type_name") %> </a>
</Itemtemplate>
</ASP: repeater>

</Div>
</Itemtemplate>
</ASP: repeater>
</Div>

Background code:

Protected void rep1_itemdatabound (Object sender, repeateritemeventargs E)
{
// Determine the position of the layer repeater in the outer repeater (alternatingitemtemplate (this template defines how to display the alternate items in the control), footertemplate (Script Template ),

// Headertemplate, itemtemplate, and separatortemplate ))

If (E. Item. itemtype = listitemtype. alternatingitem | E. Item. itemtype = listitemtype. item)
{
If (E. Item. findcontrol ("rep2 ")! = NULL)
{
Datarowview DV = (datarowview) E. Item. dataitem; // locate the data item associated with the repeater category

String pid = DV. Row ["p_typeid"]. tostring (); // obtain the ID of the fill subclass.

Repeater Rp = (repeater) E. Item. findcontrol ("rep2"); // locate the repeater object in the layer

RP. datasource = product. getp_typebyid (convert. toint32 (PID), oledbhelp. conncn );
RP. 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.