[英]How do I pass a variable size data structure back to the controller from my view in MVC?
I'm creating a view based on a list, intending to allow users to edit one or more members of the list, at the same time, on the same page. 我正在基于列表创建视图,旨在允许用户在同一页面上同时编辑列表的一个或多个成员。
I'd like to collect all of the edited (or, failing that, all) fields into a data-structure (a list or array?) to pass back to the controller, who will then update my database, as appropriate, for each element in the list. 我想将所有已编辑(或失败的所有)字段收集到数据结构(列表或数组?)中,以传递回控制器,然后控制器将根据需要为每个数据库更新我的数据库列表中的元素。
Is there an MVC .NET shorthand for building this type of view, or do I have to manually collect this data on the client side (say, with Javascript) before passing it back to the server? 是否有用于构建这种视图的MVC .NET速记,还是在将其传递回服务器之前必须在客户端(例如,使用Javascript)手动收集此数据?
You may take a look at the following blog post . 您可以查看以下博客文章 。 Also checkout the following post to better understand the expected wire format for lists and dictionaries used by the default model binder in ASP.NET MVC. 另外,请查看以下文章,以更好地了解ASP.NET MVC中默认模型绑定程序使用的列表和字典的预期连线格式。
There are a few elements to this problem: 此问题有几个要素:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.