BLOGS BY TOPIC
BLOGS BY AUTHOR
BLOGS BY YEAR
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
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
DataList Controls in ASP.NET
An example of a DataList control is shown below:
An example of a DataList control
As this diagram shows, a DataList allows you to display records in columns. This is most useful when you want to display shopping items in a two-dimensional grid.
Avoid DataList controls. Microsoft don't seem to be exactly throwing their weight behind their future support; see here for example.
Source HTML for DataList Controls
The source HTML for the above DataList is as follows:
Source HTML for the DataList above
The RepeatColumns property (shown shaded above) specifies that there will be 2 columns in the final web page.
A DataList control exposes the following events:
A DataList has a more exciting life than a repeater, but still has a fairly limited set of events that you can react to.
Microsoft introduced the ListView control in ASP.NET 3.5, to get round the limitations of the DataList control. If you want to display data in a grid or in columns, use the ListView control instead.