Copied to clipboard

Flag this post as spam?

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


  • Christina 127 posts 390 karma points notactivated
    May 21, 2018 @ 13:46
    Christina
    0

    Help with a strong typed query - from a listview

    Hi I need som help with strongtyped models query

    It's a simple Listpage - I used a listview with doctype listAllPages I want to list all children of currentpage with doctype contentPage Many Thanks/Christina The code

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ListPages>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
       @{
        IEnumerable<ListPages> list = Model.Content.Children<ContentPage>();
        foreach (ContentPage item in list)
        {
            @item.Name;
        }
        }
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 21, 2018 @ 13:49
    Alex Skrypnyk
    100

    Hi Christina

    Use this code:

    var list = Model.Content.Children<ContentPage>();
    

    The problem with code provided by you is that you declared IEnumerable

    Thanks,

    Alex

  • Christina 127 posts 390 karma points notactivated
    May 21, 2018 @ 13:54
    Christina
    0

    Thanks you so much

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 21, 2018 @ 13:54
    Alex Skrypnyk
    0

    You are welcome, have a great day!

Please Sign in or register to post replies

Write your reply to:

Draft