请教大家一个问题,我写这样的一个语句:
If IsDBNull(myDv(0)("rs_gw")) = False Then
Me.DropDownList_gw.Items.FindByValue(System.Convert.ToString(myDv(0)("rs_gw")).Trim()).Selected = True
End If
系统提示:对象未实例化,为什吗?(myDv(0)("rs_gw")的值是存在的啊)
谢谢!
If IsDBNull(myDv(0)("rs_gw")) = False Then
Me.DropDownList_gw.Items.FindByValue(System.Convert.ToString(myDv(0)("rs_gw")).Trim()).Selected = True
End If
系统提示:对象未实例化,为什吗?(myDv(0)("rs_gw")的值是存在的啊)
谢谢!
引用: myDv = Me.myPlan.Selectdw("where (rs_zt='3' or rs_zt='4')")
好像没问题阿,而myDv(0)("rs_gw")的值确实存在,为什吗?急
Dim myCommon As DataRule.CommonRule = New DataRule.CommonRule
Dim myDv As DataView = New DataView
Dim intI As Integer = 0
myDv = myCommon.SelectAllgw()
Me.DropDownList_gw.Items.Clear()
Dim firstItem As ListItem = New ListItem
firstItem.Value = "0"
firstItem.Text = ""
Me.DropDownList_gw.Items.Add(firstItem)
For intI = 0 To myDv.Count - 1
Dim myItem As ListItem = New ListItem
myItem.Value = System.Convert.ToString(myDv(intI)("bh"))
myItem.Text = System.Convert.ToString(myDv(intI)("mc"))
Me.DropDownList_gw.Items.Add(myItem)
Next
End Function
并且已经起作用
dropdownlist.Items.FindByValue就会出错,看看dropdownlist是在什么时候绑定的
If Not Page.IsPostBack Then
Me.gwBind()
end if