Description and detailed introduction of ASP.net repeater control and its application _php skills

Source: Internet
Author: User
The Repeater control does not have built-in rendering capabilities, which means that the user must provide a layout for the Repeater control by creating a template. When the page runs, the Repeater control renders an item for each record in turn through the records in the data source.

He is very simple, not enough to use, but the old saying, how to kill the chicken with a sledgehammer, do not use what? Are we going to bite the chicken? And we often face this choice in everyday applications, assuming we show the teaching of complex data, we can use the GridView, The general complexity of using DataList, so simple data rendering it? We use repeater, because he is simple, small, the most important is flexible.

We say that he does not have the built-in rendering capabilities, so we have to use some templates to implement his data rendering. By the way, when it comes to presentation, I have to say that he didn't give you the ability to add static items, in other words, he only works with the database, and most people don't talk to you.

The following table describes the templates that are supported by the Repeater control.
Template Properties Description
ItemTemplate
Contains HTML elements and controls that you want to render once for each data item in your data source.

AlternatingItemTemplate
Contains HTML elements and controls that you want to render once for each data item in your data source. Typically, you can use this template to create different skins for alternating items, such as specifying a background color that is different from the one specified in ItemTemplate.

HeaderTemplate and FooterTemplate
Contains the text and controls that are rendered separately at the beginning and end of the list.

SeparatorTemplate
Contains the elements that are rendered between each item. A typical example might be a straight line (using an HR element).


We define a good format in these templates, when the Web page is presented, it will be more beautiful, of course, you do ugly, it is impossible to beautiful.

Another Item sample must be defined
If the Repeater control does not specify a data source, it will not appear, and if there is no data in the specified data source, the header and the foot template will continue to appear.

For this control we have to talk about the following main points

1, understand several templates for the control
2, simple and practical repeater control to achieve data reading and rendering.
3, to achieve the control of the use of the insert sleeve
4, the implementation of data paging (my blog previously posted on the repeater outside the use of control pagination, but always feel bad, this time we put pagination in the footer template to make the control more beautiful)
5, let our data entry become a link, and only in this way, he is complete.

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.