Is it possible to pass my model which I used in a view back to my controller in MVC3?
In my QuestionModel I have:
private List<QuestionModel> _questionList = new List<QuestionModel>();
Which I use in my view:
//GetQuestionList returns the _questionList
foreach (var item in Model.GetQuestionList()){...}
I want to acces my model开发者_开发知识库 in the controller when I submit my form in the view.
I have tried to add the model as a parameter in de controller function like:public ActionResult SaveData(QuestionModel model){}
But I get nothing in it So my question is, is it possible and how to do it?
You will need to bind back to the type of Model
and use a for
loop not a for each
loop in your view.
精彩评论