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 a Razor script that creates a list of subpages and list them by a set number of items and orders them.
But I need to reverse the OrderBy function, so that the most recent nodes get listed first.
My razor file looks like this:
@inherits umbraco.MacroEngines.DynamicNodeContext@{ var numberOfItems = 2; }<ul> @foreach (var item in @Model.Children.Where("Visible").Take(numberOfItems).OrderBy("UpdateDate")) { <li> <a href="@item.Url">@item.Name</a> </li> }</ul>
I am pretty sure its a fairly simple thing to achieve, but im new to Razor :) Can anyone tell me how to do this?
here is a simple come from the other post:
var events =newDynamicNode(1109).GetChildrenAsList.Items.OrderByDescending((dynamic dn)=> dn.dateTime);
That doesn't seem to work at all... Just gives an error.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
OrderBy descending or ascending - How to?
I have a Razor script that creates a list of subpages and list them by a set number of items and orders them.
But I need to reverse the OrderBy function, so that the most recent nodes get listed first.
My razor file looks like this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ var numberOfItems = 2; }
<ul>
@foreach (var item in @Model.Children.Where("Visible").Take(numberOfItems).OrderBy("UpdateDate")) {
<li>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
I am pretty sure its a fairly simple thing to achieve, but im new to Razor :) Can anyone tell me how to do this?
here is a simple come from the other post:
That doesn't seem to work at all... Just gives an error.
is working on a reply...