Sorting Typed View

Posts   
 
    
timt
User
Posts: 14
Joined: 13-Nov-2006
# Posted on: 13-Nov-2006 14:46:06   

Hi

I have just started using the product V2.0.0.0final SelfService with ASP .Net 2.0 and have a simple formview on a page that I am databinding to. I have dropped on the form several LLBLGenProDataSource's and have bound them to some Typedviews and bound the dropdown's to the datasources. All works OK so far but I need to sort them. I have sorted the view in the db but that does not help, so I guess I need to sort the datatable or collection before it's bound. What is the best way to do this? I was hoping it could be done codeless but If I have to manually load, sort bind it then so be it. Any help welcomed!

Thanks Tim

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 13-Nov-2006 15:43:08   

Hello,

You can add a sorting clause in the FetchTypedView Method.

In Vb it can be done as it where "MyEntityFields.MyField" is the fields on which you want to sort :

Dim sorterChoice As ISortExpression = New SortExpression( _ New SortClause(MyEntityFields.MyField, Nothing, SortOperator.Descending)) myTypedList.Fill(0, sorterChoice, True, bucket)

If you don't have predicate you could let bucket at nothing. After you can bind your typedlist to your dropdown.

Althought in the datasource you can use the property "SorterToUse" in the llbldatasource like that :

Me.llblDataSource.SorterToUse = New SortExpression(EntityFields.Field Or SortDirection.Descending)

but in two case you have to write code behind.