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.
The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together.
What are DataGrid and GridView? We can use DataGrid controls only for data selection. GridView control can use sorting, paging, deletes and updates . GridView introduces new column types.
Programmatic access to the ListView object model to dynamically set properties, handle events, and so on. Multiple key fields. GridView Displays the values of a data source in a table where each column represents a field and each row represents a record.
The main difference between ListView and GridView is how it lays out its child. With ListView you are laying your children one by one either vertically or horizontally only. With GridView, its a combination of both. It lays its children horizontally first.
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 -
https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx
The GridView
control is the successor to the DataGrid
control. Like the DataGrid
control, the GridView
control was designed to display data in an HTML table. When bound to a data source, the DataGrid
and GridView
controls each display a row from a DataSource
as a row in an output table.
Both the DataGrid
and GridView
controls are derived from the WebControl
class. Although it has a similar object model to that of the DataGrid
control, the GridView control also has a number of new features and advantages over the DataGrid
control, which include:
Differences between the GridView
control and the DataGrid
control include:
Sorting, paging, and in-place editing of data requires additional coding when using the DataGrid
control. The GridView
control enables you to add sorting, paging, and editing capabilities without writing any code. Instead, you can automate these tasks, along with other common tasks such as data binding to a data source, by setting properties on the control.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With