dropdownlist二级联动问题,求救
现在的情况是dropdownlist1可以完整地显示7个选项,但不管怎么选择,dropdownlist2死活就是空白,代码如下,请帮我看看怎么改,谢谢PrivateSub...
现在的情况是dropdownlist1可以完整地显示7个选项,但不管怎么选择,dropdownlist2死活就是空白,代码如下,请帮我看看怎么改,谢谢
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sql As String = "select distinct 车型 from 零件信息表"
Dim mycomm As New SqlClient.SqlCommand(sql, myconn)
Dim mydatareader As SqlClient.SqlDataReader
If Not IsPostBack Then
If (myconn.State = ConnectionState.Closed) Then
myconn.Open()
End If
mydatareader = mycomm.ExecuteReader()
Me.Dropdownlist1.DataSource = mydatareader
Me.Dropdownlist1.DataTextField = "车型"
Me.Dropdownlist1.DataBind()
myconn.Close()
End If
End Sub
Private Sub Dropdownlist1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dropdownlist1.SelectedIndexChanged
Session("cartype") = Dropdownlist1.SelectedValue.ToString
Dim sql1 As String = "select distinct 名称 from 零件信息表 where 车型='" & Session("cartype") & "'"
Dim mycomm1 As New SqlClient.SqlCommand(sql1, myconn)
Dim mydatareader1 As SqlClient.SqlDataReader
If Not IsPostBack Then
If (myconn.State = ConnectionState.Closed) Then
myconn.Open()
End If
mydatareader1 = mycomm1.ExecuteReader()
Me.Dropdownlist2.DataSource = mydatareader1
Me.Dropdownlist2.DataTextField = "名称"
Me.Dropdownlist2.DataBind()
myconn.Close()
End If
End Sub 展开
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sql As String = "select distinct 车型 from 零件信息表"
Dim mycomm As New SqlClient.SqlCommand(sql, myconn)
Dim mydatareader As SqlClient.SqlDataReader
If Not IsPostBack Then
If (myconn.State = ConnectionState.Closed) Then
myconn.Open()
End If
mydatareader = mycomm.ExecuteReader()
Me.Dropdownlist1.DataSource = mydatareader
Me.Dropdownlist1.DataTextField = "车型"
Me.Dropdownlist1.DataBind()
myconn.Close()
End If
End Sub
Private Sub Dropdownlist1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dropdownlist1.SelectedIndexChanged
Session("cartype") = Dropdownlist1.SelectedValue.ToString
Dim sql1 As String = "select distinct 名称 from 零件信息表 where 车型='" & Session("cartype") & "'"
Dim mycomm1 As New SqlClient.SqlCommand(sql1, myconn)
Dim mydatareader1 As SqlClient.SqlDataReader
If Not IsPostBack Then
If (myconn.State = ConnectionState.Closed) Then
myconn.Open()
End If
mydatareader1 = mycomm1.ExecuteReader()
Me.Dropdownlist2.DataSource = mydatareader1
Me.Dropdownlist2.DataTextField = "名称"
Me.Dropdownlist2.DataBind()
myconn.Close()
End If
End Sub 展开
展开全部
不好意思,实在是看不下去了.
看的我头晕目眩的,实现你说的数据库操作哪用你这么麻烦的啊.
vb 中有很多的数据库控件的,你要实现的问题几句代码就可以了.
我昨天刚答的别人的,和你的情况差不多.你看着改改吧.
用 datalist控件,很省事.
http://zhidao.baidu.com/question/53779770.html
看的我头晕目眩的,实现你说的数据库操作哪用你这么麻烦的啊.
vb 中有很多的数据库控件的,你要实现的问题几句代码就可以了.
我昨天刚答的别人的,和你的情况差不多.你看着改改吧.
用 datalist控件,很省事.
http://zhidao.baidu.com/question/53779770.html
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询