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