Copied to clipboard

Flag this post as spam?

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


  • Christina 111 posts 344 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 5908 posts 22603 karma points MVP 4x 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 111 posts 344 karma points notactivated
    May 21, 2018 @ 13:54
    Christina
    0

    Thanks you so much

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    May 21, 2018 @ 13:54
    Alex Skrypnyk
    0

    You are welcome, have a great day!

  • 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