Hello everyone,
I am working on MVC 5, there I have Viewmodel Class ' PartnersVM '.
- public class PartnersVM
- {
- public List
listCountry { get; set; } - public PartnerVM listPartnerVM { get; set; }
- }
- public class CountryVM
- {
- public int idCountry { get; set; }
- public string countries_name { get; set; }
- }
- public class PartnerVM
- {
- public string ServiceDistricts { get; set; }
- public string ServiceStates { get; set; }
- }
- [HttpGet]
- public ActionResult PremiumUserRegistration()
- {
- PartnersVM objcountrymodel = new PartnersVM();
- objcountrymodel.listCountry = new List
(); - objcountrymodel.listCountry = objPartnerBIL.ShowCountries().Select(item => new CountryVM
- {
- idCountry = item.idCountry,
- countries_name = item.countries_name
- }).ToList();
- return View("PremiumUserRegistration", objcountrymodel);
- }
View:
- @Html.DropDownListFor(model => model.listCountry, new SelectList(Model.listCountry, "idCountry", "countries_name"), "Select", new { @class = "form-control ", @id = "ddlcountries", @onchange = "return getuserstate.search(this.value)" })
- @Html.DropDownListFor(model => model.listPartnerVM.ServiceStates, Enumerable.Empty<SelectListItem>(), "Select Country", new { @id = "ddlstate", @class = "form-control ", @onchange = "return getdistricts.search(this.value)" })
- @Html.DropDownListFor(model => model.listPartnerVM.ServiceDistricts, Enumerable.Empty<SelectListItem>(), "Select State", new { @id = "ddlDistrict", @class = "form-control " })
Now, all are working fine. But the problem is, I can not rebind those drowdown list while moving on edit page. Here Add/Edit page is one. How can I rebind the dropdownlist?
Please help me...

Ibrahim SiddiquePosted Mar 7, 2017, 10:48 AM
Abhilash J APosted Mar 7, 2017, 10:30 AM
Ibrahim SiddiquePosted Mar 7, 2017, 10:19 AM
Abhilash J APosted Mar 7, 2017, 10:15 AM
Ibrahim SiddiquePosted Mar 7, 2017, 10:05 AM