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