In your view, use the following structure:
@using (Html.BeginForm())
{
for (int i = 0; i < Model.Questions.Count(); i++)
{
@Html.TextBoxFor(model => model.Questions[i].QuestionText, new { placeholder = "Text otázky" })
<table>
@for (int j = 0; j < Model.Questions[i].Answers.Count(); j++)
{
<!-- Answer block -->
<tr>
<td>@Html.CheckBoxFor(model => model.Questions[i].Answers[j].IsCorrect)</td>
<td>@Html.TextBoxFor(model => model.Questions[i].Answers[j].AnswerText)</td>
</tr>
}
</table>
@Html.TextBoxFor(model => model.Questions[i].QuestionComment)
<!-- Question block END -->
}
<input type="submit"/>
}
This code should help you fill out the view correctly, and also pass the model to the view correctly.
Update
You can test the following actions:
public ActionResult Send()
{
CreateSurveyModel model = new CreateSurveyModel();
model.Questions = new List<QuestionModel>()
{
new QuestionModel()
{
QuestionText = "1",
QuestionComment = "Comment 1",
Answers = new List<AnswerModel>()
{
new AnswerModel()
{
AnswerText = "A1",
IsCorrect = false,
},
new AnswerModel()
{
AnswerText = "A2",
IsCorrect = true,
},
new AnswerModel()
{
AnswerText = "A3",
IsCorrect = false,
},
new AnswerModel()
{
AnswerText = "A4",
IsCorrect = true,
},
}
},
new QuestionModel()
{
QuestionText = "2",
QuestionComment = "Comment 2",
Answers = new List<AnswerModel>()
{
new AnswerModel()
{
AnswerText = "A5",
IsCorrect = false,
},
new AnswerModel()
{
AnswerText = "A6",
IsCorrect = false,
},
new AnswerModel()
{
AnswerText = "A7",
IsCorrect = false,
},
new AnswerModel()
{
AnswerText = "A8",
IsCorrect = true,
},
new AnswerModel()
{
AnswerText = "A9",
IsCorrect = false,
},
}
}
};
return View(model);
}
[HttpPost]
public ActionResult Send(CreateSurveyModel model)
{
return View();
}
. , .