开发者

MVC - DropDownList wrong option selected when value from model is null

开发者 https://www.devze.com 2023-03-20 05:20 出处:网络
I have two DropDownLists in form, both displaying list of regions. First is required, second not, stored as null in db.

I have two DropDownLists in form, both displaying list of regions. First is required, second not, stored as null in db. When I open the page for edit and first dropdownlist is ie. Region 2, and the second is null, the first option "< not specified >" should be selected in second dropdownlist, but the same op开发者_如何学JAVAtion as in first dropdownlist is selected. When I check for null in controller and set the property to value, which is not in the dropdownlist, ie. -1, it selects corrects first option "< not specified >".

Is there a way to recieve the first option selected, when the model value for this dropdown is null ?

kubiix

0

精彩评论

暂无评论...
验证码 换一张
取 消