Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have this view code:
@foreach (var qa in Model.QuestionsAnswers)
//don't want to cast this,
//but I want to use the QuestionAnswer strongly typed model
var qaModel = (QuestionAnswer)qa;
QuestionsAnswers in this case is a Nested Content Collection. I have a strongly typed model created by UmbracoModelsBuild Tool for it called QuestionAnswer.
It has Model.Question and Model.Answer in there.
If you see the code, I'm casting it because I know it's the correct model for the data. But I don't like it to put it simply.
I'd rather get the model but I'm not quite sure how to do that.
If I was working in a child view and wanted the parent model I'd do
var parentModel = Model.Parent<ParentModelName>();
How do I do the same for the nested content collection?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted