Wise Owl's Blog
Making Sense of Software

Excel | Microsoft training in London, UK

OVERVIEW OF DATA CONTROLS IN ASP.NET 4.0

Part two of a five-part series of blogs

With the introduction of the ListView data control in ASP.NET 3.5, there are now 4 separate tools for displaying multiple rows of data in ASP.NET. Which one is best - GridView, Repeater, DataList or ListView?

  1. Data Controls in ASP.NET 4.0 - Multiple Rows
  2. Repeater Web Server Controls in ASP.NET (this article)
  3. DataList Controls - ASP.NET data controls
  4. GridView Controls - ASP.NET data controls
  5. ListView Controls - ASP.NET data controls
Posted by Andy Brown on 19 September 2011 | no comments

Repeater Web Server Controls in ASP.NET

An example of a Repeater control is shown below:

Example of a repeater

Example of a repeater

Here every other row appears in a different colour.

Source HTML for a Repeater

The source HTML for the repeater shown above is as follows (I haven't shown the data source here, but it's a simple SELECT statement):

Repeater HTML source code

The source code for the repeater above

Here is the HTML that this generates:

The HTML generated by this repeater

The HTML generated by this repeater

Thus a typical repeater has:

  • The <table> tag in the header section, together with a title row
  • One row in each item or alternating item template
  • The </table> end table tag in the footer section

Repeater Events

The Repeater control exposes the following events:

Repeater events

The Repeater control doesn't support many events (compare this to the GridView control shown later in this blog).

 

Conclusion and Recommendation

The Repeater control is good for one thing only - creating simple web pages of pure HTML.  If you're using ASP.NET to create websites where you can only use pure HTML, repeaters are for you!  Otherwise, we'd ignore them and use the much more powerful gridviews instead.

OVERVIEW OF DATA CONTROLS IN ASP.NET 4.0

Part two of a five-part series of blogs

With the introduction of the ListView data control in ASP.NET 3.5, there are now 4 separate tools for displaying multiple rows of data in ASP.NET. Which one is best - GridView, Repeater, DataList or ListView?

  1. Data Controls in ASP.NET 4.0 - Multiple Rows
  2. Repeater Web Server Controls in ASP.NET (this article)
  3. DataList Controls - ASP.NET data controls
  4. GridView Controls - ASP.NET data controls
  5. ListView Controls - ASP.NET data controls

Comments on this blog

This blog currently has no comments.