Repeater nested binding Repeater

Source: Internet
Author: User

Repeater nested repeater structure: Generally, you can understand it after writing it.

CSCode:

 

Code
Private   Void Rptypebind ()
{ // Getquestiontypeandcount () returns a datatable
This . Rptypelist. datasource = Liftquestionctr. getquestiontypeandcount ();
This . Rptypelist. databind ();
}
Protected   Void Rptypelist_itemdatabound ( Object Sender, repeateritemeventargs E)
{

//Determine the position (alternatingitemtemplate, footertemplate,

// Headertemplate, itemtemplate, separatortemplate)
If (E. Item. itemtype = Listitemtype. Item | E. Item. itemtype = Listitemtype. alternatingitem)
{
Repeater rep = E. Item. findcontrol ( " Rpquestionlist " ) As Repeater; // Find the repeater object in the layer
Datarowview rowv = (Datarowview) E. Item. dataitem; // Locate the data item associated with the category Repeater
Int Typeid = Convert. toint32 (rowv [ " Qtid " ]); // Obtains the ID of the fill subclass.
Rep. datasource = Liftquestionctr. getsomequestionsbytypeid (typeid, 2 );
Rep. databind ();
}
}

 

Aspx:

Code
< Table border = " 0 " Cellpadding = " 0 " Cellspacing = " 0 " Style = " Margin-bottom: 5px " Width = " 100% " >
< ASP: repeater runat = " Server " ID = " Rptypelist " Onitemdatabound = " Rptypelist_itemdatabound " >
< Itemtemplate >
< Tr >
< TD Class = " FB " >
& Nbsp; & Nbsp; < A href = " Lists. aspx? Qtid = <% # eval ( " Qtid " ) %> " > <% # Eval ( " Qtypename " ) %> </ A >   < SPAN ID = " Askcount_15 "
Class = " Date2 " > [ <% # Eval ( " Typecount " ) %> ] </ Span >
</ TD >
</ Tr >
< Tr >
< TD >
< Div ID = " Asktop2_15 "   Class = " Ask_list " >
< ASP: repeater runat = " Server " ID = " Rpquestionlist " >
< Itemtemplate >
< A href = " Question. aspx? Qid = <% # eval ( " Liftquestionid " ) %> " >
<% # Eval ( " Questiontitle " ) %> </ A > < BR />
</ Itemtemplate >
</ ASP: Repeater >
</ Div >
</ TD >
</ Tr >
</ Itemtemplate >
</ ASP: Repeater >
</ Table >

 

 

 

This method should be suitable for repeater nesting and datalist nesting.

(Datalist nesting has been tried not long ago. It can also be)

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.