But how could you live and have no story to tell!
访问统计 original graphics

ListBoxItems.FindByValue("string”).Selected = true;

出现了“未将对象引用设置到对象的实例”的错误。在网上查了很久终于找到了解决办法。

Items.FindByValue(i)返回了一个null, 以至于调用Selected属性抛出异常. 通常调用FindByText, FindByValue这种情况下都需要做一下null检查:
ListItem li = cbl.Items.FindByValue(i);
if(li != null) li.Selected = true;

ListItem li = ZH.Items.FindByValue(role);
if (li != null) li.Selected = true;

posted on 2009-06-17 10:03  nextsoft  阅读(1178)  评论(0编辑  收藏  举报