What's New for Tabular List Controls in ASP.NET 2.0?|
The Repeater, DataList, and DataGrid controls are available in ASP.NET 2.0, but you'll find they offer no major feature enhancements. You'll use them mostly for backward compatibility with ASP.NET 1.x Web applications.
One of the best improvements to the existing tabular list controls (as well as to all ASP.NET 2.0 controls) is called adaptive page rendering. All ASP.NET controls now provide support for mobile devices, which eliminates the need to produce separate Web pages and controls that target the specific device detected.
ASP.NET 2.0 also introduces two new tabular list controls: GridView and DetailsView, which provide a more robust feature set and require even less back-end code to support them. For example, the GridView provides paging and sorting (as the DataGrid does), but requires no server-side code in order to support these features.
You use the GridView control as you do the DataGrid: for displaying a data source in classic rows and columns format. Unlike the DataGrid, you don't need to use any back-end code to update your data source from within a GridView's inline editing feature. However, you'll still need to use a minimal amount of server-side code for insertions and deletions.
The GridView also supports additional column types and template tags, giving you even more control over your rendered output. For example, the new SummaryTitleStyle, DetailTitleStyle, and DetailLinkStyle templates allow you to override the look and feel of the rendered output on mobile device screens.
In addition, the GridView exposes additional events that allow you to place custom code. For example, the GridView has a RowDeleting event that fires when the user requests the deletion of a row, but before the row in the data source is actually deleted. This gives you the ability to write custom code to check for things such as cascading deletes before the record is actually removed from the data source. Similar events also exist for editing, updating, canceling, paging, and sorting commands.
You can also place bound Checkbox fields, Image fields, Dropdown list fields, and a free-form field called a Template field within the GridView columns. You can achieve the same end result with the DataGrid, but it requires a huge amount of custom server-side code.
The DetailsView control provides a record-by-record view of the detail, together with support for inline editing. This view's format is similar to the Microsoft Access record-editing user interface. By inserting a DetailsView control and binding it to a data source, you can provide a standalone review and editing page for a single data source. You can also link the DetailsView to the GridView to provide a master-details data-entry page for your data source. All of these features require a fraction of the server-side code ASP.NET 1.x tabular list controls require.