简体   繁体   中英

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?

您将需要绑定回Model的类型,并在视图中使用for循环而不是for each循环。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM