Sequential list inconsistency not working

In accordance with this article, I am trying to link a list of unclassified items.

View:

<%using (Html.BeginForm("Products", "Home", FormMethod.Post)) { %> <input type="hidden" name="products.Index" value="cold" /> <input type="text" name="products[cold].Name" value="Beer" /> <input type="text" name="products[cold].Price" value="7.32" /> <input type="hidden" name="products.Index" value="123" /> <input type="text" name="products[123].Name" value="Chips" /> <input type="text" name="products[123].Price" value="2.23" /> <input type="hidden" name="products.Index" value="caliente" /> <input type="text" name="products[caliente].Name" value="Salsa" /> <input type="text" name="products[caliente].Price" value="1.23" /> <input type="submit" value="Submit" /> <%} %> 

Action method:

 [AcceptVerbs(HttpVerbs.Post)] public ActionResult Products(IList<Product> products) { return View("Index"); } 

Binding does not work for me, parameter products always contain zero. Did I miss something?

Any help is greatly appreciated, thanks.

Please note that I am using ASP.NET MVC 1.0

+3
c # asp.net-mvc model-binding
Oct 18 '11 at 12:22
source share
1 answer

The default mediator is able to associate collections with unclassified indexes starting with ASP.NET MVC 2.0. This is not supported in ASP.NET MVC 1.0.

+7
Oct 18 '11 at 12:40
source share



All Articles