コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }