ASP.NET Grid View vs. List View

Mugunth picture Mugunth · May 21, 2009 · Viewed 48.7k times · Source

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?

Answer

niaher picture niaher · May 25, 2009

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.