Data Controls[5]->Repeater
The Repeater control displays data items in a repeating list. Similar to DataList, the content and layout of list items in Repeater is defined using templates. At a minimum, every Repeater must define an ItemTemplate; however, the following optional templates may be used to customize the appearance of the list.
Unlike DataList, Repeater has no built-in layout or styles. You must explicitly declare all HTML layout, formatting, and style tags within the templates of the control. For example, to create a list within an HTML table, you might declare the <table> tag in the HeaderTemplate, a table row (<tr> tags, <td> tags, and data-bound items) in the ItemTemplate, and the </table> tag in the FooterTemplate.
The following samples illustrate using a simple Repeater control.
| Template Name | Description |
|---|---|
| ItemTemplate | Defines the content and layout of items within the list. Required. |
| AlternatingItemTemplate | If defined, the AlternatingItemTemplate determines the content and layout of alternating items. If not defined, ItemTemplate is used. |
| SeparatorTemplate | If defined, the SeparatorTemplate is rendered between items (and alternating items). If not defined, a separator is not rendered. |
| HeaderTemplate | If defined, the HeaderTemplate determines the content and layout of the list header. If not defined, header is not rendered. |
| FooterTemplate | If defined, the FooterTemplate determines the content and layout of the list footer. If not defined, footer is not rendered. |
Unlike DataList, Repeater has no built-in layout or styles. You must explicitly declare all HTML layout, formatting, and style tags within the templates of the control. For example, to create a list within an HTML table, you might declare the <table> tag in the HeaderTemplate, a table row (<tr> tags, <td> tags, and data-bound items) in the ItemTemplate, and the </table> tag in the FooterTemplate.
The following samples illustrate using a simple Repeater control.


浙公网安备 33010602011771号