Hello,
I have the following models: Department (as city), District and Store.
Department has one to many Districts
Districts has one to many Stores
I'm constructing a view where I create a new Store and the user can choose the Department(city) and then the District dropdownlist updates instantly with the corresponding districts.
For this I created this ViewModel: StoreIndexData
This is the Controller where I populate the dropdownlist for the Department:
And this is the View:
And in the end of the view, this is my JS section:
This section calls this action:
And that's it.
When I run the application, well, the District dropdownlist don't populate
_Questions:
Is it possible that I can't access this properties inside the JScript
"#DepartmentID"
Could this work using a ViewModel? I'm not adding the Department property inside the Store model because it would be irrelevant since it gets its Department thru the District.
I saw in the example that I followed that they added this line ProxyCreationEnabled = false Inside the JsonResult action. I didn't add it because I don't know what it does and don't know the consecuences in my application if I add it.
Thanks in advance for any help.
Regards,
_Update:
I put a break point on this line, inside the JsonResult:
List<District> DistrictList = _context.Districts. Where(x => x.DepartmentID == DepartmentID).ToList();
But the application did not stopped there when I used the Department dropdownlist that is supossed to call that JsonResult. I believe the script section is what might be wrong.