How to Order PageDataCollection using a bespoke property

Vote:
 

Hi,

I am trying to Sort the order of a PageDataCollection but it is not working.

I am using the following code whare EventPriority is an Int.

PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);

            // Sort the results first
            FilterPropertySort sorter = new FilterPropertySort("EventPriority", (FilterSortDirection.Ascending));
            sorter.Filter(pages);

But it does not work - can anyone help?

#152066
Edited, Aug 15, 2016 15:19
Vote:
 

That code looks good to me. How are you using the pages after they have been sorted? Have you debugged your code and stopped just after they have been sorted, to see if it actually worked?

#152074
Aug 15, 2016 18:22
Vote:
 

Hi,

We can't debug the site locally - it's funny - we have worked with Episerver for over 4 years and we have never been able to run it locally.

We just bind pages to the News List:

News.DataSource = pages;
            News.DataBind();
<EPiServer:NewsList runat="server" ID="News">
#152076
Aug 15, 2016 18:25
Vote:
 

And you're not using the sort property on the newslist webcontrol? Because that will re-sort the collection.

What happens if you change to a pagelist webcontrol instead? There might be some kind of default sorting going on in the newslist webcontrol.

#152077
Aug 15, 2016 18:31
Vote:
 

It's an odd one but I found a way to combat this issue - I have added the Sortby and SortDirection to the front end and this works.

<EPiServer:NewsList runat="server" ID="News" SortBy="EventPriority" SortDirection="Ascending">

Thanks for all your help,

Jon

#152096
Aug 16, 2016 13:27
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.