View
@for (int i = 1; i < Convert.ToInt32(Model.qc_choice) + 1; i++)
{
<span>Question @i</span>
@Html.TextAreaFor(m => m.MTfull[i].qc_selectedchoice)
<span>Answer @i</span>
@Html.TextBoxFor(m => m.MTfull[i].qc_answer)
<br />
}
<p>
<input type="submit" value="Create" name="submitBtn" />
</p>
Controller
[HttpGet]
public ActionResult checkMT(string quiz_id)
{
List<Models.QuizMaker> qm = new List<Models.QuizMaker>();
var model = new Models.QuizMaker
{
act_id = quiz_id,
};
return View(model);
}
[HttpPost]
public ActionResult checkMT(QuizMaker qm)
{
return RedirectToAction("createMatchingType", "QuizMaker", new { quiz_id = qm.act_id, choice = qm.qc_choice });
}
[HttpGet]
public ActionResult createMatchingType(string quiz_id, string choice)
{
List<Models.QuizMaker> qm = new List<Models.QuizMaker>();
var model = new Models.QuizMaker
{
act_id = quiz_id,
qc_choice = choice,
};
return View(model);
}
This is how the qc_choice is populated it is coming from the user
then it will loop the controls on how many the user inputed.
But whatever I do The value of the List MTfull model is always null in my controller help is much appreciated.