CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Sorting SortedBindingList by child object property

    Answered (Not Verified) This post has 0 verified answers | 2 Replies | 1 Follower

    Not Ranked
    2 Posts
    scjohnson posted on Wed, Apr 10 2013 9:29 AM

    Hello,

    I'm trying to sort a GridView by a property of a child object. I'm able to successfully set the DataField of a BoundField to the child column ("Application.Name"), but this doesn't work for sorting. How would I go about accessing this child property in the ApplySort method of a SortedBindingList?

     

    Thanks,

    Sam Johnson

    All Replies

    Top 10 Contributor
    2,279 Posts
    Suggested by JonnyBee

    Hi,

    SortedBindingList does not support sorting on a child property. Only properties on the actual object may be used for sorting.

    So you could add an extra property to the list to project the child property or to use LINQ with projection but that requires more code in the UI and does not support editing of the list.

     

     

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    2 Posts

    Thank you! Using this, I was simply able to add the following property to the object and was able to sort:

    public string ApplicationName
            {
                get { return this.Application.Name; }
            }
    Page 1 of 1 (3 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems