如何显示 DropDownList 的初始值?
有一个 DropDownList ,内容如下(默认显示为“苹果”):
ID 内容
1 苹果
2 西瓜
3 香蕉
。。。
数据来自数据库,用:
dList.DataSource = ds
dList.DataTextField = "Name"
dList.DataBind()
现在,要根据数据库另外一个表中的内容B改变默认显示,如B=西瓜,则 DropDownList 的默认显示为“西瓜”。
用:
dim strDL = 西瓜
dList.Items.FindByText(strDL).Selected = True
不行,错误:"未将对象引用设置到对象的实例"
该如何解决?