Dealing with "" or Null in Sort Expressions

2 posts, 0 answers
  1. Lonnie
    Lonnie avatar
    7 posts
    Member since:
    Oct 2011

    Posted 19 Oct 2011 Link to this post

    I have a sort expression that works on multiple columns in the listview, but anything that is blank in the datasource comes up first in the sort. For instance I have a name and a business, but sometimes there isn't a business associated with the name. I am sorting in the order of Business, Last Name, then First Name. The blank businesses come up first because "" or null comes before it in sort order. Is there any way to work around this.

  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 21 Oct 2011 Link to this post

    Hi Lonnie,

    As you noted yourself, this is the expected behavior of sorting and it is not within the capabilities of RadListView to change it. This is so because the RadListView is simply a bound control displaying the available data, it does not manipulate it internally.
    So, your option is to handle the sorting manually and return a collection of only the non-null records or with your custom order applied. For more information you could take a look at this help article:
    Custom Sorting

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top