A data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list.
Assembly: System.Web (in System.Web.dll)
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class Repeater : public Control, INamingContainer
The 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 control is the only Web control that allows you to split markup tags across the templates. To create a table using templates, include the begin table tag (<table>) in the HeaderTemplate, a single table row tag (<tr>) in the ItemTemplate, and the end table tag (</table>) in the FooterTemplate.
The control has no built-in selection capabilities or editing support. You can use the ItemCommand event to process control events that are raised from the templates to the control.
The control provides two properties to support data binding. To bind data to any object that implements the System.Collections::IEnumerable interface (such as a System.Data::DataView, a System.Collections::ArrayList, a System.Collections::Hashtable, or an array), or the IListSource interface, use the DataSource property to specify the data source. When you set the DataSource property, you must manually write the code to perform data binding. To automatically bind the control to a data source represented by a data source control, set the DataSourceID property to the ID of the data source control to use. When you set the DataSourceID property, the control automatically binds to the specified data source control on the first request. Therefore, you do not need to explicitly call the DataBind method unless you have changed data-related properties of the control.
A control binds its ItemTemplate and AlternatingItemTemplate to either the data model declared and referenced by its DataSource property or the data source control specified by its DataSourceID property. The HeaderTemplate, FooterTemplate, and SeparatorTemplate are not data-bound.
At a minimum, every control must define an 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, 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.
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 Control Syntax.
The following code example demonstrates how to use two simple controls on a page. The DataSource property is used to specify the data source for the control. The first displays its items in a table; the second displays its items in a comma-separated list.
The following code example demonstrates how to use the DataSourceID property to specify the data source for a control. The DataSourceID property is set to the ID property of the SqlDataSource control used to retrieve the data. When the page is loaded, the control automatically binds to the data source specified by the SqlDataSource control and the data is displayed to the user.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.