コード例 #1
0
        public List <SelectListItem> GetForeignData(List <int> selectIdList)
        {
            List <SelectListItem> data = new List <SelectListItem>();

            data = ArticleCateService.GetALL().ToList().Select(x => new SelectListItem
            {
                Text     = x.CateName,
                Value    = x.ID.ToString(),
                Selected = selectIdList.Contains(x.ID)
            }).ToList();
            return(data);
        }
コード例 #2
0
        private List <SelectListItem> GetSelectList(int value = 0)
        {
            var list = Utilities.GetSelectListData(
                articleCateService.GetALL().ToList()
                , item => item.ID
                , item => item.CateName, true).ToList();

            if (value != 0)
            {
                list.Single(x => x.Value == value.ToString()).Selected = true;
            }

            return(list);
        }
コード例 #3
0
        public ActionResult ArticleCode(int pid = 0)
        {
            var query = ArticleCateService.GetALL();

            if (pid == 0)
            {
                query = query.Where(x => x.PID.Equals(null));
            }
            else
            {
                query = query.Where(x => x.PID == pid);
            }

            var selectlist = Utilities.CreateSelectList(
                query.ToList()
                , item => item.ID
                , item => item.CateName, false);

            return(Json(selectlist, JsonRequestBehavior.AllowGet));
        }