I have an embedded content data type on one of my pages, and this has a display order field. I am using RAZOR to retrieve the embedded content items which all works fine, but I can't work out how to order the items by the display order field that I created.
My loop is as follows:
@foreach (var item in Model.colourCharts.item) { dynamic mediaItem = new DynamicMedia(item.icon.InnerText);
dynamic downloadItem = new DynamicNode(item.download.InnerText); }
And the display order field is called displayOrder. I am guessing I need to use the OrderBy LINQ function but have tried different ways and can't get it to work.
Embedded Content Display Order
I have an embedded content data type on one of my pages, and this has a display order field. I am using RAZOR to retrieve the embedded content items which all works fine, but I can't work out how to order the items by the display order field that I created.
My loop is as follows:
@foreach (var item in Model.colourCharts.item)
{
dynamic mediaItem = new DynamicMedia(item.icon.InnerText);
dynamic downloadItem = new DynamicNode(item.download.InnerText);
}
And the display order field is called displayOrder. I am guessing I need to use the OrderBy LINQ function but have tried different ways and can't get it to work.
Any ideas/solutions would be more than welcome.
Hi Graham,
In Razor you add the order functionality in the foreach statement. Like this:
I hope it works
is working on a reply...