bindaandi wrote:
Hi FritFrut,
how do you implement the sorting functionality of the Gridview with collections of type IList<>. I'm new in programming an object orientated business logic.
I only thing I found is to copy all Object of the collection in a List<> of the System.Collection.Generic Namespace witch implements the sort() Methode with a Comarpor.
Is this the way to go?
Andi
ObjectDataSource doesn't do its own sorting and paging, really. It expects you to provide methods with a certain signature (currentIndex, pageSize, maxItems, sortValue, things like that). The built-in strongly-typed DataSet functionality in .NET makes it clickity-click easy to generate methods that have such signatures -- but it's buggy and I much prefer the DataLayer style that NHibernate gives us.
However, to use make the best use of sorting, paging, and such in ObjectDataSource, the easiest way is to make a thin wrapper around NHibernate. Mark your wrapper class with the DataObjectAttribute. Mark your Get methods with DataObjectMethod(DataObjectMethodType.Select) (your Saves with DataObjectMethodType.Insert, etc.).
Finally, make sure your Get() methods have the necessary parameters for sorting and paging. (string sortColumns, int startRecord, int maxRecords). You can implement paging and sorting however you want in that method, but doing it server-side with HQL is probably the most efficient.