ASP.NET Grid View vs. List View

What are the advantages of using listview over gridview? I need pagination, editing rows, inserting rows, and deleting rows in my view. Which control is best for that? It seems like GridView does not support data pager. What would I sacrifice if I migrated my gridviews to listviews?


GridView supports:

  • sorting by click
  • paging
  • editing
  • selection
  • template-based layout (rendered within <table>)

ListView supports:

  • List item
  • paging (need to use DataPager)
  • editing
  • selection
  • sorting by click (need to create an event handler manually)
  • template-based layout (rendered as you want it + provides more templates, e.g. - GroupTemplate)

The reason to use ListView would be if you need some special layout, for example, to create a table that places more than one item in the same row, or to break free from table-based rendering altogether) - which is not possible with GridView.

Using GridView on the other hand is easier and faster, so unless you need special layout to display your data, use GridView.


This article is particularly useful for a comparison.

For me it is the raw flexibility of the HTML you can render. In a project I was developing I was using a GridView but replaced with the ListView as I wanted very specific paging requirements that couldn't be provided by the GridView. I could have used a 3rd party gridview to provide the paging requirements, but I wanted to minimise the reliance of 3rd party code.

The ListView alone in my opinion is a good reason for moving from ASP.NET 2.0 to 3.5.


Its realy depend/requirement on the scenario which control to be use
Listview is completely template driven and support of inserting records, you can use a regular html table and style it with CSS for presenting data, you have much control over design layout.
On the other hand GridView, you can insert records, but that can involve using the footer and your objectdatasource_inserting event. You need to find and capture the entered data in the gridview footer then directly add into input parameters of your objectdatasource.


ListView gives you more control over resulting HTML markup.