コード例 #1
0
        public void FillCityDropdown(int?cityId)
        {
            DataTable   dtLocation     = new DataTable();
            UserDetails objUserDetails = new UserDetails();

            dtLocation = objUserDetails.GetCity();
            IList <CityModel> items = dtLocation.AsEnumerable().Select(row =>
                                                                       new CityModel
            {
                CityId   = row.Field <int>("CityId"),
                CityName = row.Field <string>("CityName")
            }).ToList();
            var list = new SelectList(items, "CityId", "CityName", cityId);

            ViewData["CityName"] = list;
        }
コード例 #2
0
        private void FillCityDrodown()
        {
            DataTable   dtContact      = new DataTable();
            UserDetails objUserDetails = new UserDetails();

            dtContact = objUserDetails.GetCity();
            IList <CityModel> items = dtContact.AsEnumerable().Select(row =>
                                                                      new CityModel
            {
                CityId   = row.Field <int>("CityId"),
                CityName = row.Field <string>("CityName")
            }).ToList();

            var list = new SelectList(items, "CityId", "CityName");

            ViewBag.CityId = list;
        }