Exemplo n.º 1
0
        /// <summary>
        /// 获取常用PageSize
        /// </summary>
        /// <returns></returns>
        public static SelectList GetPageSize(string pagesize)
        {
            if (string.IsNullOrWhiteSpace(pagesize))
            {
                pagesize = "20";
            }
            List <int> pageSizeList = new List <int> {
                5, 10, 20, 50, 100
            };
            List <SelectListItem> itemList = new List <SelectListItem>();

            foreach (int size in pageSizeList)
            {
                itemList.Add(new SelectListItem {
                    Text = size.ToString(), Value = size.ToString()
                });
            }
            if (!pageSizeList.Contains(DataFormat.FormatInt32(pagesize)))
            {
                pagesize = "20";
            }
            SelectList retList = new SelectList(itemList, "Value", "Text", pagesize);

            return(retList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 消息状态
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public static List <MUISelectListItem> GetMsgStatus(string values)
        {
            var listValues = (values ?? string.Empty).Split(new[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <MUISelectListItem> itemList = new List <MUISelectListItem>();

            itemList.Add(new MUISelectListItem
            {
                Value    = "-1",
                Text     = "请选择",
                Selected = listValues.Contains("-1")
            });

            foreach (var value in Enum.GetValues(typeof(EnumMsgStatus)))
            {
                itemList.Add(new MUISelectListItem
                {
                    Value    = DataFormat.FormatInt32(value).ToString(),
                    Text     = value.ToString(),
                    Selected = listValues.Contains(DataFormat.FormatInt32(value).ToString())
                });
            }
            return(itemList);
        }