大问题啊 第2 个出现两次
protected conn as sqlconnection
protected mycommand as sqlcommand
protected cmd as sqldataadapter
dim ds as new dataset
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim strr As String
strr = "server=127.0.0.1;database=zdsw1;password=111111;user id=zdsw"
conn = New SqlConnection(strr)
conn.Open()
Dim strsql As String
strsql = "select * from xangyedalei_table"
cmd = New SqlDataAdapter(strsql, conn)
cmd.Fill(ds, "xangyedalei_table")
strsql = "select * from xangyezilei_table"
cmd = New SqlDataAdapter(strsql, conn)
cmd.Fill(ds, "xangyezilei_table")
If Not IsPostBack Then
‘dropsownlist的绑定
DropDownList1.DataSource = ds.Tables("xangyedalei_table").DefaultView
DropDownList1.DataTextField = "xangyedalei"
DropDownList1.DataValueField = "xid"
DropDownList1.DataBind()
DropDownList2.DataSource = ds.Tables("xangyezilei_table").DefaultView
DropDownList2.DataTextField = "xangyezilei"
DropDownList2.DataValueField = "zid"
DropDownList2.DataBind()
end sub
Private Sub dropdownlistchanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
'绑定dropdownlist2
Dim dv As DataView
dv = ds.Tables("xangyezilei_table").DefaultView
dv.RowFilter = "xid='" + DropDownList1.SelectedItem.Value + "'"
DropDownList2.DataSource = dv
DropDownList2.DataTextField = "xangyezilei"
DropDownList2.DataValueField = "zid"
DropDownList2.DataBind()
end sub
例如:dropdownlist1我选了江苏
dropdownlist2就出现想应的县市
比如南京啊
但南京 出现两次啊
怎么会事啊
不好意思没分了啊
我dropsown1autopostback=true了