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)