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?
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.
The main difference between a ListView/GridView and a DataGrid is that the latter provides editing and sorting functionality out of the box. So if you don't require to be able to edit and/or sort the data to be displayed in a tabular grid, then choose a ListView with a GridView.
The DataGrid and the GridView controls have different event models. The DataGrid control raises single events for operations, while the GridView control is capable of both pre-operation and post-operation events. The GridView control supports the Sorting event that occurs when a field is sorted.
Repeater is faster because it offers only basic data bound control rendering functionalities. If you want to show data and you don't need any complex features described below then repeater is the right joice.
GridView supports:
<table>
)ListView supports:
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.
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