public static SelectList Getunitdropdown(int UnitID) { DropDownListsRepository modelRepo = new DropDownListsRepository(); var penaltyrate = modelRepo.ReadUnit(); List<SelectListItem> _Listpenaltrate = new List<SelectListItem>(); foreach (var item in penaltyrate) { SelectListItem itr = new SelectListItem(); itr.Text = item.Name; itr.Value = item.ID.ToString(); itr.Selected = false; _Listpenaltrate.Add(itr); } return new SelectList(_Listpenaltrate, "Value", "Text", UnitID); }
public JsonResult GetUnit() { DropDownListsRepository modelRepo = new DropDownListsRepository(); return Json(modelRepo.ReadUnit().OrderBy(o => o.Name).Select(c => new { UnitID = c.ID, Unit = c.Name }).OrderBy(o => o.Unit), JsonRequestBehavior.AllowGet); }
public static SelectList Getunitdropdown(string UnitID) { DropDownListsRepository modelRepo = new DropDownListsRepository(); var unit = modelRepo.ReadUnit(); if (UnitID == null || UnitID == "0") { UnitID = "1"; } List<SelectListItem> _Listpenaltrate = new List<SelectListItem>(); foreach (var item in unit) { SelectListItem itr = new SelectListItem(); itr.Text = item.Name; itr.Value = item.ID.ToString(); itr.Selected = false; _Listpenaltrate.Add(itr); } return new SelectList(_Listpenaltrate, "Value", "Text", UnitID); }