Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Custom Entity - DropDownList - Not Saving Selected Value #10523


User avatar
0
c_emin created
  • What is your product version? v10.4.0
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? .net core

I used ASP.NET Zero Power Tools to create a new Geography Entity. I'm able to change values in regular Text input boxes and save those fields.

Then I created a DB Table to store all available Countries to be able to select from a Dropdownlist. I am able to get the available countries to show up in the dropdown list. However, when I choose a country and hit "Save" it does not save the selected country to the DB.

 [StringLength(ProfileConsts.MaxCountryLength, MinimumLength = ProfileConsts.MinCountryLength)]
 public virtual string Country { get; set; }

 [StringLength(ProfileConsts.MaxGeoCountryLength, MinimumLength = ProfileConsts.MinGeoCountryLength)]
 public virtual string GeoCountry { get; set; }

This will save changes fine <input class="form-control" id="Geography_Country" value="@Model.Geography.Country" type="text" name="country"/>

This does not save selected value @Html.DropDownList("Geography_GeoCountry", new SelectList(Model.countrylist, "CountryId", "GeoCountry", Model.Geography.GeoCountry), "Select Country from List", new { @class = "form-control" })

Is there a JQuery Function I need to execute, to update the DTO? Any help would be much appreciated.


2 Answer(s)
  • User Avatar
    0
    musa.demir created

    Can you please check the http request payload using your explorer's developer console.

  • User Avatar
    0
    c_emin created

    With your suggestion, I was able to find the request payload information and see what was going on. I had to change @Html.DropDownList("Geography_GeoCountry" to @Html.DropDownList("GeoCountry" then it started working. Thanks for your help!