Working with the Repeater

The Repeater is the most basic of the built-in list control objects, yet offers a great deal of flexibility. To format the data it displays, the Repeater uses templates. Templates are blocks of HTML mixed with server logic that define how each row in the data collection will appear when sent to the client. Templates are defined within the body of the control instantiated within the Web form.

There are a number of different types of templates. The ItemTemplate, as seen in Listing 11.1, is responsible for formatting each record in the collection. The AlternatingItemTemplate lets you define a special appearance for every other item in the collection. A typical use of this would be to define a slightly different color for ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.