Sorting a LLBLGen Pro Datasource

Posts   
 
    
Coderoid
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 08-Apr-2008 10:49:27   

Hi guys,

I have an ASP.NET DropDownList that i'd like to sort alphabetically by the Name field, but i'd like to apply sorting to the LLBLGen Pro Datasource that it is bound to. Please advise? Here is the code:

** <aspsmile ropDownList id="DropDownList1" runat="server" DataSourceID="LLBLGenProDataSource2" AppendDataBoundItems="true" SelectedValue='<%# Bind("ParentId") %>' DataValueField="Id" DataTextField="Name" OnDataBound="DropDownList1_DataBound" ><asp:ListItem Text="-No Parent-" Value="" Selected="True"/> </aspsmile ropDownList> **

and the DataSource:

** <llblgenpro:LLBLGenProDataSource ID="LLBLGenProDataSource2" runat="server" DataContainerType="EntityCollection" EntityCollectionTypeName="Eyeballs.Data.CollectionClasses.AdvertiserCollection, Eyeballs.Data" SortingMode="ClientSide" OnElementsFetched="LLBLGenProDataSource2_ElementsFetched"> </llblgenpro:LLBLGenProDataSource> **

At the moment, the fields returned by the LLBLGen Pro Datasource include Id, ParentId, Name, sActive, DateCreated, DateUpdated.

I am using LLBLGen Pro Version 2.5 (ORMSupportClasses Type: SelfServicing) on ASP.NET 2.0 and Windows XP Service Pack 2, with MS SQL Server 2005.

Thanks,

Lloyd Dube

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-Apr-2008 10:59:57   

At code behind pass (eg. PageLoad): use the following:

LLBLGenProDataSource2.SorterToUse = new SortExpression(...);
Coderoid
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 08-Apr-2008 11:06:49   

Thanks Walaa, i appreciate. I saw something to that effect in the LLBLGen docs - i'm having trouble figuring out what the argument to SorterToUse should be, i.e. what type/ format it should take.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 08-Apr-2008 16:42:25   

Please check the reference manual if you're unsure what type and VS.NET doesn't reveal it to you. simple_smile (ISortExpression btw)

Frans Bouma | Lead developer LLBLGen Pro
Coderoid
User
Posts: 7
Joined: 03-Apr-2008
# Posted on: 08-Apr-2008 16:54:59   

Hehehe okay Frans...i think you really mean, "sorry no spoonfeeding here" lol

Ciao