网格上的ForeignKey列
本文关键字:ForeignKey 网格 | 更新日期: 2023-09-27 18:20:50
我正在尝试用C#将ForeignKey列添加到Kendo UI中的网格中,该网格使用通过Linq连接到SQL的SQL Server数据库。我找不到填充组合框/下拉列表的方法。。
我有控制器(当我创建Linq-to-sql文件时,模型会自动创建)。。但我找不到填充组合框的方法。
这是代码:
c.ForeignKey(p => p.MerchantID, (IEnumerable)ViewData["Merchants"], "MerchantID", "Name").Title("Merchant").Width(150);
/********************* View ***************************************/
columns.ForeignKey(p => p.CategoryID, (System.Collections.IEnumerable)ViewData["categoryList"], "CategoryID", "Category").Title("Organization Size").HeaderHtmlAttributes(new { @class = "fontbold" }).Width(170)
//***************** Controller *************************//
List<ManageModel> lookup = vendorTask.GetVendorCategory().Select(p => new ManageVendorModel { CategoryID = p.OrganizationSizeID, Category = p.OrganizationSizeName }).ToList<ManageModel>();
lookup.Insert(0, (new ManageModel { CategoryID = 0, Category = " No Organization Size" }));
ViewData["categoryList"] = lookup;