CslaDataSource + SortedBindingList + PagedDataSource = Confusion!

CslaDataSource + SortedBindingList + PagedDataSource = Confusion!

Old forum URL: forums.lhotka.net/forums/t/1093.aspx


david.wendelken posted on Thursday, August 31, 2006

I'm trying to add paging and sorting to a DataList control that is populated from a root collection on my ASP.Net page.

Frankly, I'm confused, and I bet others are in the same boat (or will be once they try it :).

I would dearly like to see a good example of how to do this, making appropriate usage of Session variables so that:

  1. I don't have to re-query the database just to page or sort.
  2. I have full access to the actual business object collection in all event handlers without having to re-query the database.
  3. It doesn't forget the user's sorting choices when I do re-query the database. 
  4. I don't have to re-sort the list every time I do a post-back.
  5. The VS Designer properly shows the object in design mode and knows what kind of properties are available.
  6. The page never loads the unpaged business object into the grid - not even during startup - because I have so many records that it would timeout.
  7. Placing the user on the correct page so that they see the same selected record as before they sorted the list would be a nicety, but I can do that myself. :)

It seems like I need 3 session variables to hold each of the three objects (my bo collection, the sorted binding list and the paged data source). 

Do I pass the PagedDataSource into e.BusinessObject in the CslaDataSource OnSelect event handler?

david.wendelken replied on Saturday, September 02, 2006

Surely someone uses DataLists and wants to page them and let the user sort them?

RockfordLhotka replied on Monday, September 04, 2006

Well it is clear that SortedBindingList is totally useless in this context. Since you don't ever have all the data in memory, you can't sort the data in memory - it can only be sorted within your data query.

That should reduce the confusion, since you are back to using just the CslaDataSource along with a standard collection base class - presumably with the CSLA 2.1 enhancement that supports paging through the IReportTotalRowCount interface.

david.wendelken replied on Tuesday, September 05, 2006

I've been storing my collection class contents, plus the sorted binding list, plus the paged list in separate session variables.  I'm pretty sure it's working right... :)

Frankly, it hurts my head to keep the whole mess straight in my head.

I'm looking forward to trying the 2.1 version, but that will have to wait for the next release.

 

 

 

Copyright (c) Marimer LLC