how to bind distinct value in dropdown using Entity Framework in mvc 3, mvc 4 razor control?
Controller:-
private UploadEntities db = new UploadEntities();
public ActionResult Create()
{
ViewBag.Campaign = db.Assets.Select(r => r.Category).Distinct();
return View();
}
public ActionResult Create()
{
ViewBag.Campaign = db.Assets.Select(r => r.Category).Distinct();
return View();
}
View Page:-
@Html.DropDownList("Campaign", new SelectList(ViewBag.Campaign))
No comments:
Post a Comment
Thanks for comments.