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