I have some problem rendering the grid in Umbraco 8. I only have the basic out of the box from Umbraco.
I'm using Modelbuilder.
This is the error i'm getting
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedModels.Home' does not contain a definition for 'sections'
* The error is "Model.sections in the bootstap3.cshtml file" *
I had the same error, different cause - thought I'd post a solution in case anyone else googles to here.
I had a document type with some content already created. I added a Grid property, and added the standard line to the appropriate template.
@Html.GetGridHtml(Model, "Grid", "Neat3")
Then I added content, tested it and all looks great.
Unfortunately, all the other pieces of content of the same type started throwing an error as per above - does not contain a definition for 'sections'
The issue is that the Grid property is null, and GetGridHtml passes through the page Model, not the grid property, into the Partial view ... causing an exception.
Simplest fix was to wrap the rendering statement in a test:
Thanks for the hint, but I had to modify your solution a bit. As I'm using UmbracoViewPage the approach with Model.Grid showed the error, that Model doesn't contain a definition for Grid. But when I check for the value of the property with Model.Value("Grid") != null it works for me.
Render Grid
Hey,
I have some problem rendering the grid in Umbraco 8. I only have the basic out of the box from Umbraco.
I'm using Modelbuilder.
This is the error i'm getting
* The error is "Model.sections in the bootstap3.cshtml file" *
Markup
What am I doing wrong ?
Anyone ? :)
This sounds like a dumb question (because I think I have approximately the same amound of knowledge as you) but what is the content of this grid ?
I have the exact same content of your pages and this work with me...
Also, in VS you can add a breakpoint in the Bootstrap3.cshtml, put one and check if your "Model" have "sections"
Did you make a typo in the property alias?
Sorry for the late reply.
I found the error.. really stupid one.. I testet it on the english langauge layer.. But added the content to the danish layer.. :P
Need to wired my head around for Umbraco 8 :D !
I had the same error, different cause - thought I'd post a solution in case anyone else googles to here.
I had a document type with some content already created. I added a Grid property, and added the standard line to the appropriate template.
Then I added content, tested it and all looks great.
Unfortunately, all the other pieces of content of the same type started throwing an error as per above - does not contain a definition for 'sections'
The issue is that the Grid property is null, and GetGridHtml passes through the page Model, not the grid property, into the Partial view ... causing an exception.
Simplest fix was to wrap the rendering statement in a test:
It feels like the GetGridHtml or even the default rendering templates should be a bit more defensive to avoid this problem?
Thanks for the hint, but I had to modify your solution a bit. As I'm using
UmbracoViewPage
the approach withModel.Grid
showed the error, that Model doesn't contain a definition for Grid. But when I check for the value of the property withModel.Value("Grid") != null
it works for me.is working on a reply...