When I edit record country list is loaded but the city list not loaded. For example, I have saved record Country USA and City are Newyork is not loaded if the USA country selected. This function works well when I add new Add Record But Edit I use in Edit Operation I have the Problem.
C#
- List
listCountry = _ICountry.listofCountry(); - ViewBag.CountryList = new SelectList(listCountry, "CountryID", "CountryName");
- public JsonResult GetCity(int CountryID)
- {
- List
ctyList = _ILogin.GetCityList(CountryID); - return Json(ctyList, JsonRequestBehavior.AllowGet);
- }
- <div class="row">
- <div class="col-md-6">
- <label class="col-xs-3 control-label">Countrylabel>
- <div class="controls col-xs-9">
- @Html.DropDownListFor(m => m.CountryID, ViewBag.CountryList as SelectList, "Choose the Country Name", new { @class = "input-border-btm" })
- div>
- div>
- <div class="col-md-6">
- <label class="col-xs-3 control-label">Citylabel>
- <div class="controls col-xs-9">
- @Html.DropDownListFor(m => m.CityID, new SelectList(" "), "Choose City", new { @class = "input-border-btm" })
- div>
- div>
- div>
Salman BegPosted May 17, 2020, 2:13 AM