ASP.NET MVC从查看得到52文本框键/值到控制器的最佳方法 [英] MVC ASP.NET Best way to get 52 textbox key/values from View to Controller

查看:115
本文介绍了ASP.NET MVC从查看得到52文本框键/值到控制器的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这不是每个作为参数传递给控制器​​POST方法。

I'm hoping that it isn't to pass each as a parameter to the controller post method..

有52文本框格重新presenting周在一年中,每个将被包含的十进制值,需要所有的这些传递回给控制器数据库的质量更新..

Have a grid of 52 text boxes representing weeks in a year, each will be containing a decimal value, need ALL of these passed back to the controller for mass updating of the database..

编辑:添加更多的细节。

edit: Adding more details.

所以,我的动作指数();返回52的对象中有一个列表的视图。

So my action Index(); returns a view with a list of 52 objects in it.

所以

返回查看(日期);

视图里面我做的一个foreach该类型的模型中的所有对象,并实现其价值的文本框,然后我要改变他们,点击提交。

inside the view I do a foreach for all the objects of that type in the model, and put their values into textboxes, I then want to change them and hit submit.

有没有什么办法来获得更新的列表到我的文章的控制器,而不必与文本框的ID的给它52的参数?

非常感谢事先!

编辑:也许有一种方法,我可以张贴在论坛上的控制器,并通过文本框控件迭代,并走出ID /值,任何想法如何

edit: Maybe there is a way I can post the forum to the controller and iterate through the textbox controls and get out id/value, any idea how?

推荐答案

我会用模型绑定建议:

http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC.aspx

http://www.singingeels.com/Articles/Model_Binders_in_ASPNET_MVC__Part_2.aspx

这篇关于ASP.NET MVC从查看得到52文本框键/值到控制器的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆