The Repeater control is a container control that allows you to create custom lists out of any data that is available to the page. The Repeater control does not have a built-in rendering of its own, which means that you must provide the layout for the Repeater control by creating templates. When the page runs, the Repeater control loops through the records in the data source and renders an item for each record.
Because the Repeater control has no default look, you can use it to create many kinds of lists, including the following:
A table layout.
A comma-delimited list (for example, a, b, c, d, and so on).
An XML formatted list.
In Design view, right-click the Repeater control, and then click Show Common Control Tasks.
On the Common DropDownList Tasks menu, click Choose Data Source.
In the Data Source Configuration Wizard, choose a source for the Repeater control. For more information, see Configure a data source by using a data bound control.
To use the Repeater control, you create templates that define the layout of the control's content. Templates can contain any combination of markup and controls. If no templates are defined, or if none of the templates contain elements, the control does not appear on the page when the application is run.
In Code view, place the insertion point inside the <asp:Repeater></asp:Repeater> tags.
Press the less than key (<) to open the code completion drop-down.
Click the template you want to create.
Type the HTML you want for the template. For an example of template definitions, see How in the MSDN library.
The following list describes the Repeater templates that are supported by the Repeater control:
ItemTemplate Contains the HTML elements and controls to render once for each data item in the data source.
AlternatingItemTemplate Contains the HTML elements and controls to render once for every other data item in the data source. Typically, this template is used to create a different look for the alternating items, such as a different background color than the color that is specified in the ItemTemplate.
HeaderTemplate and FooterTemplate Contains the text and controls to render at the beginning and end of the list, respectively.
SeparatorTemplate Contains the elements to render between each item. A typical example might be a line (using an HR element).
For additional information about using the Repeater control, see Repeater Web Server Control Overview in the MSDN library.