Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have some news items that are sorted by the "Create date" value.
Now that the client are moving all the old news from their old site to this new site I have made a date picker so it's possible for the client to set the old date of the news.
How can I with razor first sort after the date picker I have made and if the client haven't specified a date then sort after the normal "Create date"?
Thanks in advance.
If you have a list that inherits from IQueryable then just use Linq like this:
IEnumerable<YourItem> sortedItems = items.OrderBy(i => i.FirstDate).ThenBy(i => i.SecondDate);
If you require descendend sorting, the use OrderByDescending and ThenByDescending.
I'm not using Linq but just normal Razor.
Is it possible when I just have some nodes with my own "Publishdate" value and the "Create date" value and then sort the nodes with Razor?
Just import Linq in your view using
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted