"ASP." Parsing templates for repeater controls

Source: Internet
Author: User

1.Repeater controls:

as the name implies, repeat have repeated meanings. An explanation is a list of items that are used to display duplicates, which are restricted to that control. The Repeater control does not have built-in rendering capabilities, and the user must create a template to provide it with a layout .

Repeating things means that there are a lot of the same, so you can draw them out. What you pull out, object-oriented, is called a class, which can be a template method in design mode. In the Repeater control here, it's called a template .

This blog mainly summarizes the use of the 5 Repeater control templates and effect display.


2. Five Types of templates:
1> ItemTemplate:

Each data item is formatted.

Assuming that repeater is a table, it has multiple rows, and each row shows data that is ItemTemplate controlled. The data bindings here can also be bound by the DataSource property.


Cases:

       <span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >  <ItemTemplate>                <font color= "Red" size= ">//Font color red, size                    : <% #DataBinder. Eval ( Container.DataItem, "UserName")%>                    <% #DataBinder. Eval (Container.DataItem, "userpwd")%>                   <br >//Line wrapping                </font>          </ItemTemplate></span>
Results:


In the above data binding when the use of DataBinder.Eval, you can see the difference between Eval and DataBinder.Eval.


2> AlternatingItemTemplate:

Set each alternating data item.

If you set both ITemplate and AlternatingItemTemplate in your code, the first row of data is shown in the settings in ItemTemplate, and the second row is displayed in the settings in AlternatingItemTemplate. This alternately displays the data that is bound.

The data binding here is the same as the data binding in the above template. If only one of the above templates is set in the code, the data is displayed according to the settings of the selected template.

  code:

               <ItemTemplate>                   <font color= "Red" size= ">         <%--Font color red, size 20--%>                              <%# DataBinder.Eval (Container.DataItem, "UserName")%>                     <% #DataBinder. Eval (Container.DataItem, "userpwd")% >                     <br>                           <%--//line--%>                       </font>                 </ItemTemplate>              <strong> </ strong> <alternatingitemTemplate>                     <font color= "Blue" >                         <% #DataBinder. Eval ( Container.DataItem, "UserName")%>                         <% #DataBinder. Eval (Container.DataItem, "userpwd")%>                     <br ></font>               </alternatingitemTemplate>
Results:

3> separatortemplate:

Sets the delimiter. data binding is not possible in this template.

The following example adds a blue line.

Code:

            <SeparatorTemplate>                     
Results:



4> HeaderTemplate and FooterTemplate

Set the header and footer. It is important to note that there is no data binding in the header and footer template.

Code:
         <span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >     <HeaderTemplate>                   

Results:            
Summary:The first two templates can be data-bound, and the last three templates cannot be data-bound. The ITemplate template is required, and the rest of the templates can be selected to add if required. 

"ASP." Parsing templates for repeater controls

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.