How to add sorting to RolesEdit.aspx

How to add sorting to RolesEdit.aspx

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


david.wendelken posted on Thursday, August 17, 2006

If I add the ability to sort using SortedBindingList the way I've learned to in other threads to RolesEdit, I get the following error:

Error 1 Cannot implicitly convert type 'Csla.SortedBindingList<ProjectTracker.Library.Role>' to 'ProjectTracker.Library.Roles' .  It's happening on the aquamarine line...  Also happens for the Insert, Update and Select functions.

protected void RolesDataSource_DeleteObject(
object
sender, Csla.Web.DeleteObjectArgs e)
{
  try
  {
    ProjectTracker.Library.Admin.Roles obj = GetRoles();

Here's the GetRoles spec:

private SortedBindingList<Role> GetRoles()

I tried casting the GetRoles() function result to Roles, but it says it can't convert that. 

Do I have to have two different GetRoles types of functions, one that returns a sorted value and one that does not?  Seems a bit klunky to do that, particularly as it might gum up the sorted cached results.

Thanks!

david.wendelken replied on Friday, August 18, 2006

I got it to work, but it smells of rotten fish.

I created a GetUnsortedRoles function that returns a Roles list instead of a SortedBindingList<Role>.

Of course, since the problem is that I can't figure out how to get from a SortedBindingList<Role> to a Roles collection, I can't make use of the cached SortedBindingList<Role> like we do in GetRoles().

So, everytime someone wants to delete, update, or insert a record, I have to ignore the cache.  Rather defeats the purpose of having one in an edit screen.

And, of course, it forgets the sorting instruction, so it returns from those operations sorted totally different from the user's last sort request.  (I hope I can fix that by interrogating the cached SortedBindingList to find out how it is sorted, and reapplying the sort when the update/delete/insert operation is done.)

Surely there has to be a better way!!??

david.wendelken replied on Friday, August 18, 2006

I made it work, but it's ugly. 

Anybody know a better way?

Copyright (c) Marimer LLC