我想結合我的razor
看法,但得到的錯誤控制:如何綁定模型控制在MVC 4
這裏是我的Order
型號:
public class OrderViewModel
{
public int Id { get; set; }
public AreaCatalog Area { get; set; }
[Display(Name="Sub Total")]
public int SubTotal { get; set; }
public int Discount { get; set; }
[Display(Name = "Delivery Fee")]
public int DeliveryFee { get; set; }
[Display(Name = "Total Amount")]
public int TotalAmount { get; set; }
public List<ProductViewModel> Product { get; set; }
}
包含在ProductOrderViewModel如下:
public class ProductOrderViewModel
{
public List<ProductViewModel> Products { get; set; }
public List<OrderViewModel> Orders { get; set; }
}
這裏是我的控制器代碼:
public ActionResult Edit()
{
ResponseModel result = new ResponseModel();
result = new Logic().GetProducts();
//var model = new ProductOrderViewModel() { Products = result.Model, Orders = yy };
var model = new ProductOrderViewModel() { Products = result.Model };
if (result.Success)
return View(model);
return View();
}
這裏是我的視圖代碼:
@model ProductOrderViewModel
@using Helpers
@using ViewModels;
@{
ViewBag.Title = "Edit";
}
@Html.EnumDropDownListFor(m => m.Orders.Area, new { @name = "area", @style = "width:295px; height:25px;margin-left:5px;" })
和錯誤是:
不包含關於「區域」和沒有擴展方法「區域」接受類型的第一個參數定義「系統.Collections.Generic.List
請指導我這個問題
什麼行是錯誤? – Oluwafemi
@Oluwafemi包含EnumDropDownListFor的行。 – ARC
你可以在課堂上看到什麼? – Oluwafemi