Friday, July 09, 2004

(.NET - ASP.NET) Introducing the ASP.NET 2.0 GridView and DetailsView Controls

The ASP.NET 2.0 framework introduces two new controls for working with database data: the GridView control and the DetailsView control. You use the GridView control when working with a set of database records. The DetailsView control is used when working with individual records.

The GridView control is the successor to the DataGrid control. While Microsoft ASP.NET 2.0 still includes the DetailsGrid control, you are encouraged to take advantage of the new features of the GridView control.

The GridView control enables you to perform many of the same tasks as you would previously perform with the DetailsGrid control. The advantage of the GridView control is that, in many cases, you can perform these tasks without writing any code. The GridView control enables you to:

Display a set of database records.
Sort a set of database records.
Page through a set of database records.
Edit a set of database records.
In addition, unlike the DetailsGrid control, the GridView control enables you to sort and page through database records without requiring a postback to the server. The GridView control, optionally, uses client-side script to enable you to sort and page database records without performing a form post.

The DetailsView control is an entirely new control introduced with ASP.NET 2.0 that enables you to work with individual database records. You can use the DetailsView control on its own, to display or edit a single database record. When used in conjunction with the GridView control, you can use the DetailsView control to quickly build master/detail forms.