MVC - 当模型值为空时,DropDownList 选择错误选项
我的表单中有两个 DropDownList,都显示区域列表。第一个是必需的,第二个不是,在数据库中存储为 null。 当我打开页面进行编辑时,第一个下拉列表是 ie。区域2,第二个为空,第一个选项“<未指定>”应在第二个下拉列表中选择,但选择与第一个下拉列表中相同的选项。 当我在控制器中检查 null 并将属性设置为值时,该值不在下拉列表中,即。 -1,它选择更正第一个选项“<未指定>”。
当此下拉列表的模型值为 null 时,有没有办法接收选定的第一个选项?
库比克斯
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 option 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论