如何使用 javascript 或从控制器获取 MVC Web 网格下拉列值
我们在 ASP.NET MVC 3.0 WebGrid 中有一个下拉列表列。用户将从该列表中为每一行选择一个项目。 当我单击提交时,我需要捕获每行的选定值。 谁能给我一个从控制器执行此操作的示例代码。
提前致谢
We have a dropdown list column in ASP.NET MVC 3.0 WebGrid. User will select a item from that list for each row.
When i click on submit I need to capture the selected value for each row.
Can anyone please give me a sample code for doing this from controller.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 html 帮助程序使用 DropDownList 控件创建一个列:
然后将整个网格放入“form”语句中,该语句引用控制器中的“Save”操作,并创建该“Save”操作方法,如下所示:
You can make a column with DropDownList control using a html helper:
Then put the whole grid in a "form" statement, which refers to "Save" action in your controller, and create that "Save" action method like this:
为什么不尝试一下 telerik.mvc grid 呢?它非常流畅,可以很好地处理此类场景。此外,设置它的工作量也相当少。
您可以将其下载为 nuget 包。
示例在这里 http://demos.telerik.com/aspnet-mvc/grid
Why don'y you give telerik.mvc grid a try. It's super smooth and handles such scenarios pretty well. Moreover the effort is pretty less in setting it up.
You can download it as a nuget package.
Examples are here http://demos.telerik.com/aspnet-mvc/grid