When repeater is nested, attributes can be bound to the subrepeater.

Source: Internet
Author: User
Code

<Asp: repeater id = "repeater1" runat = "server">
<Itemtemplate>
<% # Eval ("name") %>
<HR/>
<Asp: repeater id = "repeater2" runat = "server" datasource = '<% # eval ("list") %>'>
<Itemtemplate>
<% # Eval ("stuname") %> <% # eval ("stusingle") %>
</Itemtemplate>
</ASP: repeater>
<HR/>
</Itemtemplate>
</ASP: repeater>

When repeater is nested, attributes can be bound to the subrepeater.

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{

Teacher th = new teacher (){
Name = "first"
};
Teacher Th1 = new teacher (){
Name = "second"
};

Th2.list. Add (new student (){
Stuname = "stu1 ",
Stusingle = "student"
});
Th2.list. Add (new student ()
{
Stuname = "stu2 ",
Stusingle = "student"
});
Th2.list. Add (new student ()
{
Stuname = "stu3 ",
Stusingle = "student"
});
Teacher th3 = new teacher (){
Name = "third"
};

List <teacher> List = new list <teacher> ();
List. Add (th );
List. Add (2nd );
List. Add (th3 );

This. repeater1.datasource = List;
This. repeater1.databind ();
}
}

Public class teacher
{
Private string name;

Public string name
{
Get {return name ;}
Set {name = value ;}
}

Private list <student> list;

Public list <student> List
{
Get {return list ;}
Set {list = value ;}
}

Public Teacher ()
{
List = new list <student> ();
}
}

Public class student
{
Private string stuname;

Public String stuname
{
Get {return stuname ;}
Set {stuname = value ;}
}
Private string stusingle;

Public String stusingle
{
Get {return stusingle ;}
Set {stusingle = value ;}
}

}

 

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.