views:

16

answers:

0

So, this question may be a little vague, but I have constant discussions about it:

When designing an Asp.Net page, a lot of times you might just want to throw a quick and dirty GridView on the page. When you are going that route you have the various datasource options (I typically use ObjectDataSource tied to a business object) and you can also manually bind.

I have seen a lot of variation on what datatypes can automatically provide the sorting functionality within the grid. I have seen people literally translate their custom POCO collections into DataTables in their business objects so that GridViews can more easily support these types of behavior.

You can really get a lot of different behaviors out of a GridView by handling all of the available events yourself (OnSorting, OnUpdating, etc.) and it can end up highly customized in the long run. Even though this is the case, you can run into sneaky other little problems like not having the ability to use the "Enter" key automatically perform the update operation for a given row. This is because the default button on the page might be outside the GridView, and ASP.Net only lets you specify the default button for a given panel and does not honor this behavior for buttons inside GridView templates. That is just an example, mind you. There also is of course the question about whether or not the page should go back to the data source upon each filter operation or whether or not the entire datasource should be cached in ViewState on the page to allow filter/sorting without a trip to the DB...

So here is the ultimate question: Is it reasonable to use a GridView on a page where you want basic CRUD operations even if it might mean transforming your custom collections into some kind of DataTable? Should GridViews be abandoned completely in favor of something else like a DataList, ListView, or Repeater? The latter options certainly might be more flexible, but does that mean handling the default row selection, editing, sorting, etc. functionality of the GridView should be rebuilt for each scenario?

Any reasonable thoughts on this subject appreciated!

related questions