System.Web.UI.WebControls.Repeater Class

A data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list.

See Also: Repeater Members


[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.RepeaterDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public class Repeater : System.Web.UI.Control, System.Web.UI.INamingContainer


In this topic:


The System.Web.UI.WebControls.Repeater control is a basic templated data-bound list. It has no built-in layout or styles, so you must explicitly declare all layout, formatting, and style tags within the control's templates.

The System.Web.UI.WebControls.Repeater control allows you to split markup tags across the templates. To create a table using templates, include the begin table tag (<table>) in the Repeater.HeaderTemplate, a single table row tag (<tr>) in the Repeater.ItemTemplate, and the end table tag (</table>) in the Repeater.FooterTemplate.

The System.Web.UI.WebControls.Repeater control has no built-in selection capabilities or editing support. You can use the Repeater.ItemCommand event to process control events that are raised from the templates to the control.


This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.

Data Binding

The System.Web.UI.WebControls.Repeater control provides two properties to support data binding. To bind data to any collection that implements the IEnumerable interface (such as a System.Data.DataView, a ArrayList, or an array), or the System.ComponentModel.IListSource interface, use the Repeater.DataSource property to specify the data source. When you set the Repeater.DataSource property, you must manually write the code to perform data binding. To automatically bind the System.Web.UI.WebControls.Repeater control to a data source represented by a data source control, set the Repeater.DataSourceID property to the System.Web.UI.Control.ID of the data source control to use. When you set the BaseDataList.DataSourceID property, the System.Web.UI.WebControls.Repeater control automatically binds to the specified data source control on the first request. Therefore, you do not need to explicitly call the BaseDataList.DataBind method unless you have changed data-related properties of the System.Web.UI.WebControls.Repeater control.

A System.Web.UI.WebControls.Repeater control binds its Repeater.ItemTemplate and Repeater.AlternatingItemTemplate to either the data model declared and referenced by its Repeater.DataSource property or the data source control specified by its Repeater.DataSourceID property. The Repeater.HeaderTemplate, Repeater.FooterTemplate, and Repeater.SeparatorTemplate are not data-bound.

If the System.Web.UI.WebControls.Repeater control's data source is set but no data is returned, the control renders the Repeater.HeaderTemplate and Repeater.FooterTemplate with no items. If the data source is null, the System.Web.UI.WebControls.Repeater is not rendered.


At a minimum, every System.Web.UI.WebControls.Repeater control must define an Repeater.ItemTemplate. However, other optional templates described in the following table can be used to customize the appearance of the list.


Defines the content and layout of items within the list. This template is required.


If defined, determines the content and layout of alternating (zero-based odd-indexed) items. If not defined, Repeater.ItemTemplate is used.


If defined, is rendered between items (and alternating items). If not defined, a separator is not rendered.


If defined, determines the content and layout of the list header. If not defined, a header is not rendered.


If defined, determines the content and layout of the list footer. If not defined, a footer is not rendered.

Declarative Syntax




Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,