Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Dudek 14 posts 84 karma points
    Jun 16, 2016 @ 06:32
    Bo Dudek
    0

    Ordering a dynamic nodelist by custom property

    Hi

    I have a dynamic nodelist called newsitems. I output from this using the following:

    @foreach (var newslistitem in newslist.Distinct()){

    .. and it works great. But when outputting I need to order by the custom property called dateWritten.

    Suggestions?

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jun 16, 2016 @ 08:16
    Dennis Aaen
    0

    Hi Bo,

    Have you tried to do something like this

    @foreach (var newslistitem in newslist.Distinct().OrderBy("dateWritten")){ 
    
    }
    

    Hope this helps,

    /Dennis

  • Bo Dudek 14 posts 84 karma points
    Jun 16, 2016 @ 08:20
    Bo Dudek
    0

    Hi

    Thanks, but I have already tried this. It then casts this one in the log: http://cl.ly/453R2Q2u0A3Y

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jun 16, 2016 @ 08:34
    Dennis Aaen
    0

    Hi Bo,

    Okay what if you do something like this.

    @foreach (var newslistitem in newslist.Distinct().OrderBy(x => x.GetPropertyValue<string>("dateWritten")){ 
    
    }
    

    If the dateWritten property is not at string then try change the type so it matched.

    Hope this helps,

    /Dennis

  • Bo Dudek 14 posts 84 karma points
    Jun 16, 2016 @ 08:41
    Bo Dudek
    0

    Hi

    You are missing a ")" but even though I add this, then I still get an error. This time the error is http://cl.ly/312D0e2U400u

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies