Ali Jafari
Ali Jafari

Reputation: 13

Cascading dropdown list in asp .net core

All guids I try using cascade dropdown lists States and Cities but return "undefined" Model file States.cs : enter image description here

Model file Cities.cs : enter image description here

controller: enter image description here

view file Cities.cshtml : enter image description here

cities table: enter image description here

states table: enter image description here

after run project and select a state show this result: enter image description here

Upvotes: 0

Views: 565

Answers (1)

Rena
Rena

Reputation: 36615

Please add console.log(cities) to check the response:

$.each(data, function (i, cities) {
    console.log(cities); //add this...
    items += "<option value='" + cities["citiesId"] + "'>" + cities["cityName"] + "</option>";
});

Then you will find the property name in response is camel case.

So you need change code like below(e.g change cities["CitiesId"] to cities["citiesId"]):

items += "<option value='" + cities["citiesId"] + "'>" + cities["cityName"] + "</option>";

Upvotes: 1

Related Questions