Пример #1
0
        /// <summary>
        ///文章类别下拉列表
        /// </summary>
        /// <param name="selectedValue"></param>
        /// <returns></returns>
        public static List <SelectListItem> GetArticleTypeOneSelectList(int?selectedValue = null)
        {
            List <SelectListItem> listResult = new List <SelectListItem>();
            var firstSelectItem = new SelectListItem()
            {
                Text = "---未指定---", Value = null
            };

            listResult.Insert(0, firstSelectItem);


            var productSpecList = ArticleTypeManager.GetInstance().SelectList(m => m.isdelete == false && m.parentid == 0);

            if (productSpecList == null)
            {
                return(listResult);
            }

            var tmpList = productSpecList.Select(m => new SelectListItem()
            {
                Text = m.title.ToString(), Value = m.id.ToString()
            });

            listResult.AddRange(tmpList);

            //设定为选中状态
            listResult.ForEach(m =>
            {
                if (selectedValue.ToString() == m.Value)
                {
                    m.Selected = true;
                }
            });
            return(listResult);
        }
Пример #2
0
 public static ArticleTypeManager GetInstance()
 {
     return(_instance ?? (_instance = new ArticleTypeManager()));
 }