Sorting bound Typed List

Posts   
 
    
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 04-Aug-2009 22:27:38   

This will compile but crashes with a cast error (RoleDetails is a TypedList):

 protected void gvRoleDetails_Sorting(object sender, GridViewSortEventArgs e)
        {
            var op = e.SortDirection == SortDirection.Ascending ? SortOperator.Ascending : SortOperator.Descending;
            var clause = new SortClause((IEntityField) RoleDetails.GetFieldsInfo()[e.SortExpression], op);
            var sortExpression = new SortExpression(clause);

How do we get GetFieldsInfo() to work with a Sort Clause?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Aug-2009 23:03:10   

This can be done - see this thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11085

However you do need to know the name of the ENTITY that the field belongs to - not the tpyed list. The entity name could be supplied as another property of your sender object ?

Matt

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 04-Aug-2009 23:16:35   

MTrinder wrote:

This can be done - see this thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11085

However you do need to know the name of the ENTITY that the field belongs to - not the tpyed list. The entity name could be supplied as another property of your sender object ?

Matt

Thanks Matt.

However I don't want to have to pull the entity name separately just for this. There has to be a way since just binding a typed list using a llbl datasource allows sorting.

The problem seems to be that SortClause needs an EntityField while GetFieldInfo returns EntityField2 and there seems to be no way to go back and forth that I can find -- very annoying.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Aug-2009 06:27:18   

Steve,

Are you using Adapter or SelfServicing? LLBLGenPro version?

David Elizondo | LLBLGen Support Team
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 05-Aug-2009 13:54:38   

daelmo wrote:

Steve,

Are you using Adapter or SelfServicing? LLBLGenPro version?

Adapter. Is there an alternative to SortClause that can accept an IEntityField2?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 05-Aug-2009 14:01:47   

For Adapter, the sortClause has overloads that accepts IEntityFieldCore, which is a superType of EntityField2.

Please check the reference manual.

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 05-Aug-2009 14:09:45   

Walaa wrote:

For Adapter, the sortClause has overloads that accepts IEntityFieldCore, which is a superType of EntityField2.

Please check the reference manual.

That fixed it. Should have known I guess. You learn these things when you work with LLBLgen long enough!

Thanks.