ASP.NET Whidbey Overview
page 5 of 14
by Steven Smith
Feedback
Average Rating: 
Views (Total / Last 10 Days): 56714/ 226

GridView / DetailsView

If you've done any heavy lifting with ASP.NET, you've probably at least played with the DataGrid control.  This is the "Mother of All Controls" in ASP.NET 1.x, being one of the biggest honkin' web controls around.  However, despite its wealth of functionality, it still requires a ton of code to get to do anything beyond displaying data in a single fashion.  Since one of the goals of Whidbey was to reduce total code written by 2/3, the DataGrid was targeted for some major overhaul work to help address this issue.  The most common things that are added to the standard DataGrid, each of which requiring more code than the last, are paging, sorting, and editing. 

The answer is the GridView.  Want to add paging?  Just turn it on and it works.  Want sorting?  Same deal.  Bidirectional sorting?  No problem.  Editing?  Again, it just works.  Even databinding, which for the DataGrid requires at least a line of code to call .DataBind() has been streamlined so that it can be done without any code by using the new fooDataSource controls (where foo is the type of Data Source).

An example GridView from the Pubs database with paging and sorting enabled (and no code required) is shown here:

GridView

With a minimal amount of code, this GridView can be modified to include support for Master-Detail viewing, where selecting an author will update a separate GridView showing that author's titles.  Further, selecting a title will bring it up in a DetailsView for editing, again with little or no code.  Here's a completed page, built on the PDC Preview build of Whidbey, which rolls these features together and uses less than 10 lines of code.

GridView and DetailsView

Although the object model for the GridView is very similar to the DataGrid, its Columns collection is populated with fooField objects, rather than fooColumn objects.  For example, while a DataGrid has a BoundColumn control, the GridView has a BoundField.


View Entire Article

User Comments

Title: very good article   
Name: raja raja
Date: 2009-12-04 7:57:23 AM
Comment:
very good and informative website.
Title: nice artical   
Name: abdulla hussein
Date: 2007-04-29 6:28:16 AM
Comment:
I like it , it is very informative . thanks alot man

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-09 4:03:16 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search