我想要做的是SelectList
从类别存储库中填充类别。一个小样机http://mockupbuilder.com/App/15379。
我现在拥有的是一个控制器:
[HandleError]
public class ProductController : Controller {
private IRepository<Product> exhibitions;
private IRepository<Category> categories;
private readonly Int32 PageSize = 18;
// ctor ...
[HttpPost]
public ActionResult Create(Product product, Guid categoryId) {
// validation ...
// properties setting ...
product.Category = categories.Get(categoryId);
return View(product);
}
类别类是这样的:
public class Category : AbstractEntity<Category> {
public String Title { get; set; }
public String Description { get; set; }
}
我如何填充一个SelectList
?我该如何使用JSON
?
谢谢!