Copied to clipboard

Flag this post as spam?

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


  • Maxi 13 posts 152 karma points
    Jun 04, 2015 @ 13:15
    Maxi
    0

    Converting doc type to Composition doc type

    Hey,

    I am currently having an issue where I have several doc types which has a composition of Featured Image. I have used a multi node tree picker on another node which allows you to pick these Nodes that have the composition of Featured Image, so I am trying to convert these nodes during a foreach to "FeaturedImage", however, I get the error

    Unable to cast object of type 
    'Umbraco.Extensions.Models.Generated.GeneralContent' to type 
    'Umbraco.Extensions.Models.Generated.FeaturedImages'.

    When using the code below:-

     @foreach (var CTA in Model.CtaPages.RandomOrder().Take(2).ToList().ConvertAll<FeaturedImage>(x => (FeaturedImage)x))
            {
    //Content would appear hear
    }

    Any help advise on if this can be done and how to do it would be greatly appreciated.

    Thanks

    Maxi

Please Sign in or register to post replies

Write your reply to:

Draft