Hello,
I'm revisiting this issue as I now have to find a solution for my users. I need to allow sorting on the gridview columns. My gridview is bound to a csladatasource. A while back I had found some code that implemented sorting using linq, but it seems the csladatasource does not play nicely with the implementation.
I am hoping someone has a solution for sorting, and hopefully it's implemented on the csladatasource.
I am using csla.net 3.5 with .net 3.5 framework. Please see:
SelfSortingGridView - GridView from www.singingeels.com
Thanks,
Andrew
The CSLA .NET Version 2.1 Handbook ebook has a section that walks through the various sort options available when using CSLA. In general the model relies on ASP.NET data binding providing the sort column and direction, along with page and item count values for paging, which it does with the standard Microsoft controls at least, and probably with third party controls I assume.
That information is provided in the arguments to the select event that is raised by the CslaDataSource. In other words, you get that information provided to you in your select event handler. At that point there are four possible places for you to do a sort (or filter):
Options 1 and 2 are the least efficient (usually), but are easy to do with LINQ to Objects or the Csla.SortedBindingList class.
Options 3 and 4 are usually much more efficient and how they work depends on your data access technology and/or database.
Thanks Rocky. I was able to implement osrting this way:
Protected Sub dsAssetTransferList_SelectObject(ByVal sender As Object, ByVal e As Csla.Web.SelectObjectArgs) Handles dsAssetTransferList.SelectObject' get list Dim list As AssetTransferList = GetAssetTransferList() ' do sort If String.IsNullOrEmpty(e.SortExpression) Then
' return unsorted list
e.BusinessObject = list
ElseDim sortedList As New SortedBindingList(Of AssetTransferInfo)(list)
sortedList.ApplySort(e.SortProperty, e.SortDirection)
' return sorted liste.BusinessObject = sortedList
End If End SubNot the most elegant or exotic, but it works for me especially since the list object is cached; need not do a round trip to SQL.
Thanks,
Andrew.
Copyright (c) Marimer LLC