我試圖綁定劍道Grid.but它顯示我以下錯誤劍道UI網格結合
傳遞到詞典中的模型項的類型爲「System.Data.Entity.DbSet
1[KendoApp.Product]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1 [KendoApp .Models.ProductModels]」。
我查看
@model IEnumerable<KendoApp.Models.ProductModels>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductID);
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitPrice);
columns.Bound(p => p.UnitsInStock);
}).Pageable()
)
我的控制器
public ActionResult KendoGrid()
{
//IEnumerable<Product> products = new northwindEntities().Products;
var products = new northwindEntities().Products;
ViewBag.Products = products;
return View(products);
產品型號
public class ProductModels
{
public int ProductID { get; set; }
public string ProductName { get; set; }
public Nullable<int> SupplierID { get; set; }
public Nullable<int> CategoryID { get; set; }
public string QuantityPerUnit { get; set; }
public Nullable<decimal> UnitPrice { get; set; }
public Nullable<short> UnitsInStock { get; set; }
public Nullable<short> UnitsOnOrder { get; set; }
public Nullable<short> ReorderLevel { get; set; }
public bool Discontinued { get; set; }
}
}
什麼錯誤?如何解決這個問題?