我需要收集与另一项目从我在ASP.NET MVC项目用户相关项目的列表。我想有像波纹管的控制器的动作。

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(int x, int y, IEnumerable<int> zKeys)
{
    //Do stuff here
}

如何设置我的形式来传递数据以这种方式?如果不能提供这种特殊形式的数据,什么是通过这种类型的信息在ASP.NET MVC下一个最好的方法是什么?

有帮助吗?

解决方案

斯科特Hanselman在如何做到这一点这里的优秀文章:

<强> ASP.NET有线格式为模型绑定到阵列,列表,类别,字典 http://www.hanselman.com/blog/...BindingToArraysListsCollectionsDictionaries.aspx

其他提示

<form action="/url" method="post">
<input name="x" type="text" value="1" />
<input name="y" type="text" value="1" />

<div>
     <input name="zKeys" value="1" />
     <input name="zKeys" value="2" />
     <input name="zKeys" value="3" />
     <input name="zKeys" value="4" />
     <input name="zKeys" value="5" />
     <input name="zKeys" value="6" />
     <input name="zKeys" value="7" />
</div>

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top