当前位置: 移动技术网 > IT编程>开发语言>.net > DropDownList绑定选择数据报错提示异常解决方案

DropDownList绑定选择数据报错提示异常解决方案

2017年12月12日  | 移动技术网IT编程  | 我要评论

圭顿财富,步步惊魂电影,相泽リナ

抛出的异常信息:异常详细信息:
system.argumentoutofrangeexception: “ddltotalcostdiscount ”有一个无效 selectedvalue,因为它不在项目列表中。

原先给dropdownlist这样赋值
this.ddltotalcostdiscount.selectedvalue = obj.totalcostdiscount.tostring();

改成这样赋值
ddltotalcostdiscount.selectedindex = ddltotalcostdiscount.items.indexof(ddltotalcostdiscount.items.findbyvalue(obj.totalcostdiscount.tostring()));
​就是如果通过findbyvalue没有找到指定项则为null,而items.indexof(null)会返回-1.
如果哪里有不正确的地方,欢迎批评指正,共同进步。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网