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 FooterTemplateSet 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