views:

305

answers:

1

I recently started working with ASP.NET 3.5, having previously worked with C# and WinForms (mostly .NET 1.1) for about 6 years.

My head spins every time I need allow the user to view, add/remove or edit a list of items. This is due to the similarities, and differences, of the following controls

  • DataGrid
  • GridView
  • ListView
  • DataList

Can anyone point me in the right direction of a nice list that does a side-by-side comparison of these controls?

Which is your "favourite", or your favourite for any particular scenarios?

+1  A: 

Short answer, with the exception of listview, they all suck ;-) Depending on your particular situation, you probably want to look into a more full featured grid by a third party, such as telerik or devexpress.

long answer, it depends on what you want to be doing.

DataGrid and DataList are mostly there for backwards compatibility. GridView and DataList are better then the older versions.

GridView is for when you want to display a grid of data. It gives you CRUD (create read update delete) operations mostly for free, and also has paging and sorting mostly for free (depending on what kind of data source you are using)

DataList is for when you want a more free form list of values.

ListView (and datapager) is our brand spanking new asp 3.5 control, and is even more free form then DataList. It lets you set up a layout template with whatever you like, and an item template which will repeat for each item in the list. You stick a container element (div/panel/placeholder) into the layout template, then tell the control which one it is, and it will repeat the item template into it for each item on the list.

You can also point a DataPager control at it, and get paging mostly for free.

Depending on what kind of site you are doing, using the built in data controls (other then repeater and listview) may end up painting you into a corner, as they have alot more overhead then are needed. If it is a small one off project, that isn't much of an issue. If its a big project where perf will be an issue, I would recommend again checking out third party controls.

Matt Briggs