Beispiel #1
0
        public string GetAoption(int?pId)
        {
            string StrApp = "";

            using (var db = new ChinaEntities())
            {
                List <S_Area> model = db.S_Area.Where(k => k.cityId == pId).OrderBy(k => k.autoId).ToList();
                foreach (var item in model)
                {
                    StrApp += "<option value=" + item.autoId + ">" + item.name + "</option>";
                }
            }
            return(StrApp);
        }
Beispiel #2
0
        public List <SelectListItem> GetADropdownlist(int?pId, int?Id)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            items.Add(new SelectListItem()
            {
                Text = "-请选择 区县-", Value = ""
            });
            using (var db = new ChinaEntities())
            {
                List <S_Area> model = db.S_Area.Where(k => k.cityId == pId).OrderBy(k => k.autoId).ToList();
                foreach (var item in model)
                {
                    items.Add(new SelectListItem()
                    {
                        Text = item.name, Value = item.autoId.ToString(), Selected = pId.HasValue && item.autoId.Equals(Id)
                    });
                }
            }
            return(items);
        }