我将我的Checkout
视图与我想传递给我的Purchase
控制器以绑定到我的Purchase
视图的模型绑定。在它被传递的那一刻,该值为空。
我究竟做错了什么?
结帐视图:
@model List<BasketModels.Product>
@using (Html.BeginForm("Purchased", "Basket", FormMethod.Post))
{
// problem here
<input type="submit" value="Purchase"/>
}
采购控制器:
[HttpPost]
public ActionResult Purchased(List<BasketModels.Product> products)
产品模式:
public class BasketModels
{
public class Product
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
[DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
public decimal UnitPrice { get; set; }
public string ImageURL { get; set; }
[Display(Name = "Quantity")]
public int Quantity { get; set; }
public int Stock { get; set; }
[DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
public decimal Price { get; set; }
[DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
public decimal TotalPrice { get; set; }
}
}