Copied to clipboard

Flag this post as spam?

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

  • Allan Kirk 7 posts 97 karma points
    Feb 21, 2019 @ 06:36
    Allan Kirk

    Render grid in Umbraco 8

    I simply cannot get the grid to render in Umbraco8, and I do not know why.

    I have a page with a grid on it with the alias "contentGrid"

    I have a template file like this:

        @inherits Umbraco.Web.Mvc.UmbracoViewPage
        Layout = "master.cshtml";
    @* the fun starts here *@
    @Html.GetGridHtml(Model.Content, "contentGrid")

    As documented here

    But I get a

    'IPublishedContent' does not contain a definition for 'Content' and no accessible extension method 'Content' accepting a first argument of type 'IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

    Well, maybe I am, but I do not know which one.

    I read somewhere, that I do not need to add .Content in U8, but then I get

    No property type found with alias contentGrid

    What to do?

  • Søren Gregersen 302 posts 1205 karma points MVP c-trib
    Feb 21, 2019 @ 07:20
    Søren Gregersen


    You need to figure out what model you are trying to render. Umbraco is telling you that you are trying to render a model that does not have the "contentGrid" property.

    How is that view being used? What model are you passing on to it etc. ?

  • Allan Kirk 7 posts 97 karma points
    Feb 21, 2019 @ 10:53
    Allan Kirk

    Okay, I was trying to make the example clearer, and stumbled upon the solution. Thanks you Søren, for prompting me to do that.

    For future reference, I was missing a line, so the correct example should look like this:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Home>
    @using ContentModels = Umbraco.Web.PublishedModels;
        Layout = null;
    @Html.GetGridHtml(Model, "contentGrid")

    It looks like "

  • Bjarne Fyrstenborg 1140 posts 3225 karma points MVP 3x c-trib
    Feb 21, 2019 @ 11:30
    Bjarne Fyrstenborg

    Hi Allan

    Remember in Umbraco 8 the RenderModel has been removed and simplified, so there is no longer Model.Content just Model.

    I guess we now could have a property with alias content and access it using Model.Content using ModelsBuilder, which in v7 would cause collisions.


  • Semyon Vyskubov 7 posts 117 karma points
    Aug 08, 2019 @ 12:57
    Semyon Vyskubov

    Thank you very much! Documentation's seems to be outdated and I've created related issue.

Please Sign in or register to post replies

Write your reply to: