Posted by
Andy Brown on 19 September 2011 | no comments
Data Controls in ASP.NET 4.0 - Multiple Rows
Having just finished updating our ASP.NET courseware, I thought I'd blog
quickly about the various controls in ASP.NET 4.0 for displaying mulitiple rows
of data (while it's fresh in my mind!).
The Data Tools Available
The diagram below shows the data tools in ASP.NET 4.0:

The full range of data controls in ASP.NET 4.0, as seen from Visual Studio 2010.
The controls divide into 4 camps: data sources, multiple row data controls (the
subject of this blog), single row data controls and other tools.
Data Sources
The data source controls are:
|
Control
|
Notes |
|
AccessDataSource |
Linking to MS Access data |
|
EntityDataSource |
Linking to entity models |
|
LinqDataSource |
Use this if you're using LINQ to connect to data |
|
ObjectDataSource |
Use if you've created your own business objects |
|
SiteMapDataSource |
Used as a basis for site map control data (eg navigational menus) |
|
SqlDataSource |
Linking to SQL Server |
|
XmlDataSource |
Linking to data in XML format |
Single Row Data Controls
The controls for displaying a single record from a database are:
|
Control
|
Notes |
|
FormView |
Displays a template for all the fields in the underlying record |
|
DetailsView |
A more restricted way to display a single record in table format |
Other Controls
The "other" controls are:
|
Control
|
Notes |
|
Pointer |
Used for selection in Visual Studio |
|
Chart |
Self-explanatory? |
|
QueryExtender |
Use this with the entity or LINQ data source controls to simplify filtering of
data. |
Multiple Row Data Controls
This leaves the multiple row data controls, the subject of this article.
These are:
|
Control |
Notes |
|
Repeater |
A simple control for displaying data in tabular format
|
|
DataList |
Allows you to display data in non-table format (such as columns) |
|
GridView |
Like a Repeater, but giving you much more control over the the table of data
appears and behaves |
|
ListView |
Like a DataList, but again giving you much more control over how the data looks
and behaves |
In addition, you can use the DataPager control to enable
paging with a ListView.
Repeaters, DataLists, GridViews and ListViews
The rest of this blog gives an overview of each of the multiple row data
controls in turn. I'm hoping at some stage in the future to write full
blogs on GridViews and ListViews, and will link to them from the page if this
happens.
Our advice? Ignore Repeater and DataList
controls, use GridViews extensively, and learn ListView controls only if you
have to because you want to present data in something other than a table format.