<p>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:</p>

<p>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?</p>

<p>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.</p>

<p><strong>Edit:</strong> 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.</p>

[{'answer_id': 4243, 'author': 'Brandon Wood', 'author_id': 423, 'author_profile': 'https://Stackoverflow.com/users/423', 'pm_score': 3, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 4244, 'author': 'Kev', 'author_id': 419, 'author_profile': 'https://Stackoverflow.com/users/419', 'pm_score': 7, 'selected': True, 'text': '<p>DataGrid was an ASP.NET 1.1 control, still supported. GridView arrived in 2.0, made certain tasks simpler added different databinding features:</p>\n\n<p>This link has a comparison of DataGrid and GridView features -</p>\n\n<p><a href="https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/05yye6k9(v=vs.100).aspx</a></p>\n'}, {'answer_id': 14809, 'author': 'Andrei Rînea', 'author_id': 1796, 'author_profile': 'https://Stackoverflow.com/users/1796', 'pm_score': 1, 'selected': False, 'text': '<p>The key difference is in the ViewState management IIRC. The DataGrid requires ViewState turned on in order to have edit and sort capabilities.</p>\n'}, {'answer_id': 14819, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 3, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 308120, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>some basic diffrence between gridview and  details view</p>\n\n<p>the GridView control also has a number of new features and advantages over the DataGrid control, which include: </p>\n\n<p>· Richer design-time capabilities. \n· Improved data source binding capabilities. \n· Automatic handling of sorting, paging, updates, and deletes. \n· Additional column types and design-time column operations. \n· A Customized pager user interface (UI) with the PagerTemplate property. </p>\n\n<p>Differences between the GridView control and the DataGrid control include: \n· Different custom-paging support. \n· Different event models.</p>\n'}, {'answer_id': 11404037, 'author': 'slolife', 'author_id': 698, 'author_profile': 'https://Stackoverflow.com/users/698', 'pm_score': 1, 'selected': False, 'text': '<p>One key difference security wise is that DataGrid uses BoundColumn which does not HtmlEncode the bound data.  There is no property to turn HtmlEncoding on or off either, so you need to do it in code somehow.</p>\n\n<p>GridView uses BoundField, which does HtmlEncode by default on the bound data and it has a HtmlEncode property if you need to turn it off.</p>\n'}, {'answer_id': 21901381, 'author': 'Suhaib Janjua', 'author_id': 3240038, 'author_profile': 'https://Stackoverflow.com/users/3240038', 'pm_score': 4, 'selected': False, 'text': '<p>The <code>GridView</code> control is the successor to the <code>DataGrid</code> control. Like the <code>DataGrid</code> control, the <code>GridView</code> control was designed to display data in an HTML table. When bound to a data source, the <code>DataGrid</code> and <code>GridView</code> controls each display a row from a <code>DataSource</code> as a row in an output table.</p>\n\n<p>Both the <code>DataGrid</code> and <code>GridView</code> controls are derived from the <code>WebControl</code> class. Although it has a similar object model to that of the <code>DataGrid</code> control, the GridView control also has a number of new features and advantages over the <code>DataGrid</code> control, which include:</p>\n\n<ul>\n<li>Richer design-time capabilities.</li>\n<li>Improved data source binding capabilities.</li>\n<li>Automatic handling of sorting, paging, updates, and deletes.</li>\n<li>Additional column types and design-time column operations.</li>\n<li>A Customized pager user interface (UI) with the PagerTemplate property.</li>\n</ul>\n\n<p>Differences between the <code>GridView</code> control and the <code>DataGrid</code> control include:</p>\n\n<ul>\n<li>Different custom-paging support.</li>\n<li>Different event models.</li>\n</ul>\n\n<p>Sorting, paging, and in-place editing of data requires additional coding when using the <code>DataGrid</code> control. The <code>GridView</code> 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.</p>\n'}, {'answer_id': 49675274, 'author': 'jmoreno', 'author_id': 234954, 'author_profile': 'https://Stackoverflow.com/users/234954', 'pm_score': 0, 'selected': False, 'text': "<p>One of the differences is the HTML output.  A datagrid will output TD's for the header and a gridview will output TH's.  This can cause unintuitive changes in the display.</p>\n"}, {'answer_id': 55546706, 'author': 'Litisqe Kumar', 'author_id': 5047627, 'author_profile': 'https://Stackoverflow.com/users/5047627', 'pm_score': 1, 'selected': False, 'text': '<p><strong>DataGrid</strong></p>\n\n<ol>\n<li><code>DataGrid</code> was introduced with <code>Asp.Net 1.0</code>. </li>\n<li>For sorting we need to handle <code>SortCommand event</code> and rebind grid\nrequired and for paging we need to handle the <code>PageIndexChanged event</code>\nand rebind grid required.   </li>\n<li>Need to write code for implementing Update and Delete operations.   </li>\n<li>Does not supports auto format or style features.</li>\n<li>Performance is fast as compared to <code>GridView</code>.</li>\n</ol>\n\n<p><strong>GridView</strong></p>\n\n<ol>\n<li>GridView was introduced with <code>Asp.Net 2.0</code>.</li>\n<li>Built-in supports for <code>Paging and Sorting</code>.</li>\n<li>Built-in supports for <code>Update and Delete operations</code>.</li>\n<li>Supports auto format or style features.</li>\n<li>Performance is slow as compared to <code>DataGrid</code>.</li>\n</ol>\n\n<p>The <code>events</code> and <code>properties</code> like <code>Item</code> has changed as <code>Row</code>.</p>\n\n<p>For example,</p>\n\n<ul>\n<li><p><code>ItemCommand - RowCommand</code></p></li>\n<li><p><code>ItemDataBound - RowDataBound</code></p></li>\n<li><p><code>e.Item.ItemType - e.Row.RowType</code></p></li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/4230', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/392/']