Ok so I want make a DropDownList
from my object list
here is my getting object method
public List<Category> GetCategoriesList()
{
BaseShopEntities context = new BaseShopEntities();
List<Category> uniqCategories = (from c in context.Category
select c).Distinct().ToList<Category>();
return uniqCategories;
}
I was trying to put it into the ViewBag
like this:
ViewBag.Categories = proxy.GetCategoriesList().ToList();
If im taking only names of Categorys and parsing it to string there is no problem but I need ID too
I Want get data like this but don't know how
@Html.DropDownList("CategoryID", new SelectList(ViewBag.Categories.Name));