Reputation: 1
I am trying to display multiple dropdowns on post back on razor page in my ASP.NET MVC application inside a for loop using Dictionary<CountryCode, <selectList item with Country Selected>>
.
Unfortunately, the selected value is lost and the dropdown is displayed with default selection.
Upvotes: 0
Views: 35
Reputation: 1
Soultion found: The MVC Postback method required cleaning of ModalState as well. The Dynamically removed dropdowns were cleaned from our viewModel alone, cleaning it from the ModalState as well, solved the issue. Because: Dropdownlistfor in the back end has a field called attempted value that was causing the dropdown selected value to get wiped out.
Thanks
Upvotes: 0