Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1465 posts 1887 karma points
    Dec 13, 2013 @ 14:02
    Gordon Saxby
    0

    Getting to data without Model

    If I access a node with

    var root = @Model.AncestorOrSelf(1);
    

    How do I then loop through each row and access the cell contents?

    This works:

    foreach (var link in Model.socialMediaLinks)
    {
        <p>@link.icon - @link.name - @link.link</p>
    }
    

    but this doesn't:

    var root = @Model.AncestorOrSelf(1);
    
    foreach (var link in root.socialMediaLinks)
    {
        <p>@link.icon - @link.name - @link.link</p>
    }
    

    Why?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 13, 2013 @ 14:09
    Dennis Aaen
    1

    Hi Gordon,

    What if you try this one:

    var root = Model.AncestorOrSelf(1);

    foreach(var link in root.socialMediaLinks){
       
    <p>@link.icon - @link.name - @link.link</p>
    }

    Does it make any difference?

    /Dennis

  • Gordon Saxby 1465 posts 1887 karma points
    Dec 13, 2013 @ 14:32
    Gordon Saxby
    100

    Thanks Dennis, that worked!! (I blame it on not having had lunch yet ;-)

    Oh ... can someone un-mark this as the solution, as it should be the post above!!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 13, 2013 @ 14:33
    Dennis Aaen
    0

    Hi Gordon,

    I´m glad that I could help you out.

    /Dennis

  • 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