Google+

Friday, January 14, 2011

Difference between Data Grid anfd Grid View in ASP






The ASP.NET 1.x DataGrid control requires you to write a lot of custom code to handle common operations such as paging, sorting, editing, and deleting data. For example, while the DataGrid control can raise events when the user clicks to save or cancel changes, it doesn't offer much more than that. If you want to store changes to a persistent medium, such as a database, you have to handle the UpdateCommand event yourself, retrieve changed values, prepare a SQL command, and then proceed from there to commit the update.

ASP.NET 2.0 enhances the data-binding architecture, introducing a new family of components—the data source objects—which act as a bridge between data-bound controls and ADO.NET objects. These source objects promote a slightly different programming model and provide for new features and members. For data reporting purposes, your ASP.NET 2.0 applications should use the newest grid control—the GridView. The familiar DataGrid control is still supported, but it doesn't take full advantage of the specific capabilities of data source components.

The GridView control is the successor to the DataGrid and extends it in a number of ways. First, it fully supports data source components and can automatically handle data operations, such as paging, sorting, and editing, provided its bound data source object supports these capabilities. In addition, the GridView control offers some functional improvements over the DataGrid. In particular, it supports multiple primary key fields and exposes some user interface enhancements and a new model for handling and canceling events.


Datagrid..
1.Code requires to handle the SortCommand event and rebind grid required.
2.Code requires to handle the PageIndexChanged.
3.Need extensive code for update operation on data.
4.When compared to gridview less events supported.

GridView..
1.No code required.
2.No code required for PageIndexChanged.
3.Needs little code for update operation.
4.GridView supports events fired before and after database updates

Note:-Please comment and reply me.

0 comments:

Post a Comment