Then as it could return empty or null, I wrap it round an if statement. Then after that, you can loop through and get the content you need.
if(nestedContent != null && nestedContent.Any()){
foreach(IPublishedContent item in nestedContent){
@*In here you can now retrieve the content you need, e.g.*@
@Html.GetGridHtml(item.Value("wYSIWYGElement"));
}
}
var nestedContent = Model.Value<IEnumerable<IPublishedElement>>("wYSIWYGGrid");
if (nestedContent != null && nestedContent.Any()){
foreach (var item in nestedContent)
{
@*In here you can now retrieve the content you need, e.g.*@
@Html.GetGridHtml(item.GetProperty("wYSIWYGElement"));
}
}
I have used same code as above on Umbraco 8. But I am getting the below error :
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Retreive Nested Contend
Hi, I have a doctype with nestedcontent(html grids). And I have found this code on the forum(V7):
How do I use this in V8? GetPropertyValue is not supported. My code now is:
But this returns a Object reference not set to an instance of an object.
Anyone?
Hi,
For nested content this is what I typically do:
Then as it could return empty or null, I wrap it round an if statement. Then after that, you can loop through and get the content you need.
Thanks for this, this is my working code
Hello Joser,
I have used same code as above on Umbraco 8. But I am getting the below error :
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Can you please help.
Thanks,
Kusum
is working on a reply...