NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Repeater Web Control

The Repeater control is a data-bound list that renders a row for every row in the data source. You define the appearance of the Repeater rows using templates.

ASP+ Syntax

Required properties are noted in boldface type.

<asp:Repeater id="Repeater1" runat=server
   DataSource="% databindingexpression  %>"
>

   <template name="Header">
      Header template HTML
   </template>
   <template name="Item">
      Item template HTML
   </template >
   <template name="AlternatingItem">
      Alternating item template HTML
   </template >
   <template name="Separator">
      Separator template HTML
   </template >
   <template name="Footer">
      Footer template HTML
   </template >
<asp:Repeater>

Properties

Property Description
(Base control properties) The properties defined in Base Web Control Properties.
DataSource A data-binding expression that references any object that supports the ICollection interface.
Note   In ASP+ syntax, it is preferable to include the data-binding expression in single quotation marks to accommodate quoted expressions.
Items A collection of RepeaterItem objects representing individual rows in the control.

This property is only used when programming.

DataItem This property is only used when programming.
ItemIndex Returns a value indicating what row from the DataSource is being rendered.

This property is only used when programming.

ItemType This property is only used when programming.

Templates

AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row in the Repeater control. You can specify a different look for the AlternatingItemTemplate element by setting its style properties.
FooterTemplate Elements to render once when all data-bound rows have been rendered. A typical use is to close an element opened in the HeaderTemplate item (with a tag such as </TABLE>).

The FooterTemplate item cannot be data bound.

HeaderTemplate Elements to render once before any data-bound rows have been rendered. A typical use is to begin a container element such as a table.

The HeaderTemplate item cannot be data bound.

ItemTemplate Elements that are rendered once for each row in the data source. To display data in the ItemTemplate, declare one or more Web controls and set their data-binding expressions to evaluate to a field in the Repeater control's (that is, the container control's) DataSource:
First Name:
<asp:Label runat="server"
   Text="<%# Container.DataItem.FirstName %>" />
SeparatorTemplate Elements to render between each row, typically line breaks (<BR> tags), lines (<HR> tags), and so on.

The SeparatorTemplate item cannot be data bound.

Events

Event (and paramters) Description
OnItemCreated(Object sender, RepeaterItemCreatedEventArgs e) Raised in the Repeater control each time a new row is created.

The following are properties of the e events argument object:

  • e.Item   (RepeaterItem)
  • e.Item.DataItem   (Object)
  • e.Item.ItemIndex   (Integer) The "row" of the Repeater control which is being created.
  • e.Item.ItemType   (ListItemType) A value indicating the template type of the row being created.
OnItemCommand(Object sender, RepeaterItemEventArgs e) Raised in the Repeater control when an embedded control raises an event.

Properties of the e events argument object:

  • e.Item   (RepeaterItem)
  • e.Item.DataItem   (Object)
  • e.Item.ItemIndex   (Integer) The "row" of the Repeater control in which the embedded control is located.
  • e.Item.ItemType   (ListItemType) A value indicating what template type the embedded control is in.

Remarks

The Repeater control has no built-in layout or styles; you must explicitly declare all HTML layout, formatting, and style tags within the control's templates. For example, to create a list within an HTML table, you can 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 Repeater control has no built-in selection or editing support. You can create a handler for the control's OnItemCommand event to process control events that bubble from the templates to the control.

The control binds its Item and AlternatingItem templates to a data structure referenced in the control's DataSource property. (The Header, Footer, and Separator templates cannot be bound to data.) If the Repeater control's DataSource is set but no data is returned, the control renders the Header and Footer templates, but no items. If DataSource is not set, the Repeater control is not rendered at all.

Example

To be supplied.

See Also

Web Forms Controls by Function |