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?
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
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):
The source code for the repeater above
Here is the HTML that this generates:
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:
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?