private void PopulateCategoryDropDownList(object selectedCategory = null) { IEnumerable <Category> categoryQuery; using (Repos repo = new Repos()) { categoryQuery = repo.GetCategoryList(); } ViewBag.CategoryId = new SelectList(categoryQuery.Distinct().ToList(), "CategoryId", "CategoryName", selectedCategory); }
public ActionResult Index() { IEnumerable <Category> cats; using (Repos repo = new Repos()) { cats = repo.GetCategoryList(); } return(View(cats)); }