我正在开发MVC4&实体框架Application.I想要填充DropDownList,我想将Category List绑定到Dodropdown列表
IRepository Code
IList<Category> GetCategory();
知识库
public IList<Category> GetCategory() { return (from c in context.Categories select c).ToList(); }
调节器
public IList<Category> GetCategory() { return icategoryRepository.GetCategory(); }
之后我就在这里.如何将数据绑定到Dropdownlist?
<label for="ProductType">Product Type</label> @Html.DropDownListFor(m => m.ProductType,new List<SelectListItem>)
我的控制器代码
public ActionResult AddProduct() { return View(); }