public JsonResult GetTypeView() { DropDownListsRepository modelRepo = new DropDownListsRepository(); return Json(modelRepo.GetTypeView().OrderBy(o => o.ID).Select(c => new { ViewTypeID = c.ID, TypeView = c.Name }).OrderBy(o => o.TypeView), JsonRequestBehavior.AllowGet); }
public static SelectList GetTypeView() { DropDownListsRepository modelRepo = new DropDownListsRepository(); var TypeView = modelRepo.GetTypeView(); List<SelectListItem> _ListTypeView = new List<SelectListItem>(); foreach (var item in TypeView) { SelectListItem itr = new SelectListItem(); itr.Text = item.Name; itr.Value = item.ID.ToString(); itr.Selected = false; _ListTypeView.Add(itr); } return new SelectList(_ListTypeView, "Value", "Text"); }