gpt4 book ai didi

asp.net - asp net mvc 3 后 IEnumerable 模型

转载 作者:行者123 更新时间:2023-12-02 16:51:20 27 4
gpt4 key购买 nike

我在此处找到了帖子,这正是我想要的:将 IEnumerable 发布到我的 Controller 。

这是另一篇文章:

Foreach on IEnumerable property and CheckBoxFor in ASP.Net MVC

我尝试了与此非常接近的方法:

http://www.vbforums.com/showthread.php?t=652925

但是当我提交表单时, Controller 上的模型为空。

我在 ASP NET MVC 2 上找到了一种解决方案,使用 Html.BeginCollectionItem() ,但看起来他们在版本 3 上删除了此帮助程序。( http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ )。

最佳答案

只需使用字符串[]

<form action="url"> 
<input type="text" name="data" />
<input type="text" name="data" />
<input type="text" name="data" />
<input type="text" name="data" />
<input type="text" name="data" />
</form>


public ActionResult Url(string[] data){

}

这对我个人的项目很有用。虽然我还没有在复杂类型上尝试过,所以尝试一下)

关于asp.net - asp net mvc 3 后 IEnumerable 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7479742/

27 4 0