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
- Add and configure a Data Source to the page
- Add a DataRepeater Control to the page
- Set the DataSource property of the Data Repeater Control to point to the Data Source
- Add an ItemTemplate to the DataRepeater
- Add databound child controls (HTML markups or Server Controls) to the ItemTemplate
- Bind the child controls to the data using the Eval data-binding function
<td><%#DataBinder.Eval(Container.DataItem, "DataItemName")%></td>
Advertisements