Thursday, 30 March 2006

ObjectDataSource and sorting

I struck this error today - "Automatic sorting is only supported with DataView, DataTable, and DataSet". It was caused by binding a custom collection through a DataSourceObject control.

Scott Guthrie suggests in a comment to this post to either implement a custom comparer, or make use of the SortParameterName property of the ObjectDataSource control.

I ended up doing the latter, as I need to be able to sort the collection on more than one property. My middle-tier expects this as an extra parameter, and then uses a DataView to sort the DataTable before it creates the custom collection.

1 comment:

Anonymous said...

Could please post what you did, so that I can use it as an example??

I have the same problem!

thanks,
Sergio