Пример #1
0
        /// <summary>
        /// 获取下拉框数据
        /// 作者:章建国
        /// </summary>
        /// <returns></returns>
        public static SelectList GetDropDownList(int id, string firstItem)
        {
            tb_BaseBLL            _basebll = new tb_BaseBLL();
            List <SelectListItem> list     = new List <SelectListItem>();

            try
            {
                list.Add(new SelectListItem()
                {
                    Text = firstItem, Value = "-1", Selected = true
                });
                foreach (var item in _basebll.GetModelList(" pId = " + id))
                {
                    list.Add(new SelectListItem()
                    {
                        Text = item.baseName, Value = item.id.ToString()
                    });
                }
            }
            catch
            {
            }
            return(new SelectList(list, "Value", "Text"));
        }