Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 非顺序列表绑定不工作_C#_.net_Asp.net Mvc_Model Binding - Fatal编程技术网

C# 非顺序列表绑定不工作

C# 非顺序列表绑定不工作,c#,.net,asp.net-mvc,model-binding,C#,.net,Asp.net Mvc,Model Binding,根据这一点,我试图绑定一个非连续项的列表 视图: 行动方法: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Products(IList<Product> products) { return View("Index"); } [AcceptVerbs(HttpVerbs.Post)] 公共行动结果产品(IList产品) { 返回视图(“索引”); } 绑定似乎对我不起作用,参数产品总是包含null。我错过什么了吗

根据这一点,我试图绑定一个非连续项的列表

视图:


行动方法:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Products(IList<Product> products)
{
    return View("Index");
}
[AcceptVerbs(HttpVerbs.Post)]
公共行动结果产品(IList产品)
{
返回视图(“索引”);
}
绑定似乎对我不起作用,参数产品总是包含null。我错过什么了吗

非常感谢您的帮助,谢谢


请注意,我使用的是ASP.NET MVC 1.0,默认的模型绑定器能够从ASP.NET MVC 2.0开始绑定具有非顺序索引的集合。这在ASP.NET MVC 1.0中不受支持。

您在此处拼写的产品有误:
感谢您发现这一点。那是个打字错误,我现在就编辑它。好的,谢谢达林。在MVC1.0中,除了编写自定义模型绑定器之外,还有其他方法可以实现这一点吗?@User123343,我不认为有太多的可能性。事实上,升级到最新版本将是IMHO的最佳解决方案。随着即将发布的ASP.NET 4.0,您将落后4代,并积累越来越多缺少的功能。好的,非常感谢Darin的帮助。目前正在进行升级,因此我们将很快切换到.net 4.0:)
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Products(IList<Product> products)
{
    return View("Index");
}