开发者

Is it possible to pass my model which I used in a view back to my controller in MVC3?

开发者 https://www.devze.com 2023-02-24 00:48 出处:网络
In my QuestionModel I have: private List<QuestionModel> _questionList = new List<QuestionModel>();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号