A ReadOnly Collection cannot sort itself in CSLA 2.0 and higher. IN 1.x there was some code added by the community to allow this but Rocky decided that "Views" on the collection was a better way to go and the community has followed that path.
So you should retrieve your ROC from the DB and then create a SortedBindingList based on the ROC. Then the datasource of your grid is set to the SortedList.
There is no need to "pull the entire collection back" just because you are sorting. If you plan to show the user different data then you need to re-fetch that data and then re-sort it. If you happen to have "all the data" then you can just re-sort it.
Joe
1. You use a ROC (Read Only Collection) to pull data from the DB. It could have an inner Info class with whatever fields you want. Even just those 4.
2. Once you have the ROC in hand you can then use a SortedBindingList.
3. I have not used a gridview with a csladtasource so I cannot tell you how to make them work together. I programmatically sort my BOs.
4. I have used the ObjectListView extensively. In fact I avoided SortedBindingList and FilteredBindingList because I wanted to use a single control to do both. And the ObjectListView supports sorting on multiple properties which was critical. SoretdBindingList only sorts on one property. I like ObjectListView a lot. But there are some quirks to be aware of: When casting the Item back to your class you have to add the .Object property to then end of the expression. The actual item is nested one level deeper than you might expect. It was also very slow in a couple of situations. I think I had to replace it with a FilteredBindingList to get it to work well enough. I think the author (Brian Criswell)was going to tweak the code but he has been very busy moving to LA from England and starting a new job.
Joe
Joe,
I got the ObjectListView to work over the weekend - thanx for your all your help, your code worked perfectly with Brian's ObjectListView class. I am posting back on the public forum so everyone can see the final solution I came up with. Turns out that no matter what BO I used, the header sorting capabilities of the ASP:GridView will not work without a ridiculous amount of code (SQL queries, reflection, arraylist, etc.). The wizard capabilities of the control are great, but the control doesn’t expose the necessary events needed to bind the data for web based gridview control sorting. So, I tried a couple of third party gridviews and found that Infragistics2.WebUI.UltraWebGrid version 7.1 worked out of the box. Should have tried this first – I could have saved two days worth of coding…
Copyright (c) Marimer LLC