Experience with ASP.net repeater controls

Source: Internet
Author: User

Now ASP. NET provides 3 controls to display a list of data

1.Repeater 2.DataList 3.GridView

These 3 controls are different

But I chose the Repeater control, because he can control the HTML output very flexibly

So that we can write our own DIV or UL Li, etc. can achieve WEB2.0 standard Web page

The Repeater control includes 4 common templates

1. HeaderTemplate

2. ItemTemplate

3. Altertemplate

4. FooterTemplate

In general, the part that does not circulate is written in HeaderTemplate and FooterTemplate.

Let's talk about the code in ItemTemplate.

<ul>
<li><%# ((Mycs.Model.CategoryInfo) Container.DataItem). Id.tostring ()%

></li>
</ul>

I recommend using this data bonding method because if we use the eval () method, he actually uses the reflex technique.

Reflection technology reduces the execution speed of a program, and must pass a parameter, and we usually use a data table field

This increases the coupling of the program, and if we use the above code we can use the entity object directly to

Go to the state set the birds with each other why not? Oh

Besides, DataSource's bonding.

I recommend using the list<t> generics one because it's type safe, faster. Two is the object directly inside the entity object

No multiple data conversions are necessary.

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.