有很多关于如何使用内置的Model-binding功能来自动获取项目列表的示例。但它们都指的是ASP.net MVC的测试版。还提到了这个模型绑定的变化,但到目前为止,我还没有找到一个很好的来源来说明它在最终版本中是如何工作的。而且我很难有能力解释源代码:-)
因此,如果有人能向我解释如何在视图中准备一个值列表,以便将其很好地返回到特定对象的IList中,那就太好了。
感谢您的帮助
麦子
发布于 2009-06-18 11:20:33
查看:
<% using(Html.BeginForm("Retrieve", "Home")) %> { %>
<% var counter = 0; %>
<% foreach (var app in newApps) { %>
<tr>
<td><%=Html.CheckBox(String.Format("myAppList[{0}].Id", counter), app.ApplicationId) %></td>
<!-- ... -->
<td><%=Html.Input(String.Format("myAppList[{0}].SomeProperty1", counter), app.SomeProperty1) %></td>
<td><%=Html.Input(String.Format("myAppList[{0}].SomePropertyN", counter), app.SomePropertyN) %></td>
<% counter = counter + 1; %>
</tr>
<% } %>
<input type"submit" />
<% } %>控制器:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Retrieve(IList<MyAppObject> myAppList)https://stackoverflow.com/questions/910972
复制相似问题