Copied to clipboard

Flag this post as spam?

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


  • Emanuel Nilsson 2 posts 71 karma points
    Mar 20, 2020 @ 14:16
    Emanuel Nilsson
    0

    Unable to store content node data in variables

    Hello,

    I am currently expanding a site in which I need to store multiple webbinar entries under a page so that they can be rendered on the site. I can read how many nodes are the decendants of the page, but I am struggling with pulling their data into variables e.g. image (videothumbnail), title and tags.

        var videoParentNode = Umbraco.TypedContent(2218);
        var videoChildren = videoParentNode.Descendants().Where(x => x.Level == 4);
    
        foreach(var index in videoChildren){
            var videoThumbnail = videoChildren.GetPropertyValue("VideoThumbnail");
        }
    

    Currently the line giving me issues is the one inside the foreach statement. What could be the issue? This is the error message I am getting: CS1928: 'System.Collections.Generic.IEnumerable

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Mar 20, 2020 @ 23:14
    Chriztian Steinmeier
    0

    Hi Emanuel,

    Inside the loop I think you want to use the index variable instead of the collection you're iterating through? E.g.:

    foreach(var index in videoChildren){
        var videoThumbnail = index.GetPropertyValue("VideoThumbnail");
    }
    

    Hope that helps,
    Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft