.Net Repeater Control

Here are some short notes on how to use the .Net Repeater Control.

Templates

The Repeater Control consists of the following subcomponents:

  • HeaderTemplate
  • ItemTemplate
  • AlternatingItemTemplate
  • SeparatorTemplate
  • Footer Template

Place codes and HTML elements in these templates to render complete DataRepeaters.

Binding Data

Data is bound through the DataSource property and the DataBind method. Valid data sources implement the ICollection, IEnumerable or IListSource interfaces.

Implementation

  1. Add and configure a Data Source to the page
  2. Add a DataRepeater Control to the page
  3. Set the DataSource property of the Data Repeater Control to point to the Data Source
  4. Add an ItemTemplate to the DataRepeater
    1. Add databound child controls (HTML markups or Server Controls) to the ItemTemplate
    2. Bind the child controls to the data using the Eval data-binding function

        <td><%#DataBinder.Eval(Container.DataItem, "DataItemName")%></td>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s