tags:

views:

5616

answers:

5

I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know:

What is the difference between these 2 ASP.NET controls? What are the advantages or disadvantages of both? Is one any faster? Newer? Easier to maintain?

The intellisense summary for the controls doesn't seem to describe any difference between the two. They both can view, edit, and sort data and automatically generate columns at runtime.

Edit: Visual Studio 2008 no longer lists DataGrid as an available control in the toolbox. It is still available (for legacy support I assume) if you type it in by hand though.

+2  A: 

The DataGrid was originally in .NET 1.0. The GridView was introduced (and replaced the DataGrid) in .NET 2.0. They provide nearly identical functionality.

bcwood
+10  A: 

DataGrid was an ASP.NET 1.1 control, still supported. GridView arrived in 2.0, made certain tasks simpler added different databinding features:

This link has a comparison of DataGrid and GridView features -

http://msdn.microsoft.com/en-gb/magazine/cc163933.aspx

Kev
A: 

The key difference is in the ViewState management IIRC. The DataGrid requires ViewState turned on in order to have edit and sort capabilities.

Andrei Rinea
+2  A: 

If you're working in Visual Studio 2008 / .NET 3.5, you probably shouldn't use either. Use the ListView - it gives you the features of the GridView combined with the styling flexibility of a repeater.

Jon Galloway
A: 

hi

some basic diffrence between gridview and details view

the GridView control also has a number of new features and advantages over the DataGrid control, which include:

· Richer design-time capabilities. · Improved data source binding capabilities. · Automatic handling of sorting, paging, updates, and deletes. · Additional column types and design-time column operations. · A Customized pager user interface (UI) with the PagerTemplate property.

Differences between the GridView control and the DataGrid control include: · Different custom-paging support. · Different event models.