razor Html.DropdownList provide “Please select” as optionLabel AND “US” as selectedValue

后端 未结 4 1718
情话喂你
情话喂你 2021-02-01 10:21

Data:

var countries = new Dictionary();
countries.Add(\"AF\",\"Afghanistan\");
countries.Add(\"US\",\"United States\");
cou         


        
4条回答
  •  时光取名叫无心
    2021-02-01 11:15

    The answer here: ASP.Net Html.DropDownList Selected Element not Selected could also be the solution.

    You use "Countries" for the name of the dropdown and "countries" as the name of the SelectList. Try renaming one or the other to something different.

提交回复
热议问题