在大家选dropdownlist控件哪个国家时,它下面的dropdownlist的空间里马上就出现了所选国家的省份
你在选省份时,下面的dropdownlist又显示对应省份中的市?
问题:这样把dropdownlist所选的内容及时传给下一个dropdownlist,并让它在数据库把值填充进去了.
及时哦.
把数据库中的数据填充到数据库我会,但是要在选了以后及时让下一个也把值填充进去,我不会,希望高手们指点一下,写一个简单的例子.
邮箱:hanzhu555@yahoo.com.cn
最好把文件发给我.先谢谢了.
5 个解决方案
#1
顶一下
#2
这个和你的数据库有联系,就是在第一个dropdownlist选中之后,把当前的值当作过虑条件,然后把过虑后的值填充到第二个dropdownlist就可以了
#3
http://singlepine.cnblogs.com/articles/265678.html
#4
可以用数据库的当前的值当作过虑条件,
以下是我的winform的程序。你可以参考一下,dropdownlist和combox的使用差不多!!
在数据库中可以考虑用存储过程编写sql查询语句,页面载入的速度快点!
'调用数据绑定类别1的数据
Sub cboxstyle1binding()
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
sql = "select distinct(style1) from tabimgoption "
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style1")
cboxstyle1.DataSource = ds.Tables(0)
cboxstyle1.DisplayMember = "style1"
sqlconn.Close()
sqlconn.Dispose()
End Sub
'调用2数据绑定类别1的数据
Private Sub cboxstyle1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboxstyle1.SelectedIndexChanged
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
Dim style1str As String = cboxstyle1.Text.ToString
sql = "select distinct(style2) as style2 from tabimgoption where style1= '" & style1str & "'"
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style2")
cboxstyle2.DataSource = ds.Tables(0)
cboxstyle2.DisplayMember = "style2"
sqlconn.Close()
sqlconn.Dispose()
End Sub
以下是我的winform的程序。你可以参考一下,dropdownlist和combox的使用差不多!!
在数据库中可以考虑用存储过程编写sql查询语句,页面载入的速度快点!
'调用数据绑定类别1的数据
Sub cboxstyle1binding()
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
sql = "select distinct(style1) from tabimgoption "
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style1")
cboxstyle1.DataSource = ds.Tables(0)
cboxstyle1.DisplayMember = "style1"
sqlconn.Close()
sqlconn.Dispose()
End Sub
'调用2数据绑定类别1的数据
Private Sub cboxstyle1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboxstyle1.SelectedIndexChanged
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
Dim style1str As String = cboxstyle1.Text.ToString
sql = "select distinct(style2) as style2 from tabimgoption where style1= '" & style1str & "'"
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style2")
cboxstyle2.DataSource = ds.Tables(0)
cboxstyle2.DisplayMember = "style2"
sqlconn.Close()
sqlconn.Dispose()
End Sub
#5
在WebForm里时将DropDownList属性设置AutoPostBack=True;回传
#1
顶一下
#2
这个和你的数据库有联系,就是在第一个dropdownlist选中之后,把当前的值当作过虑条件,然后把过虑后的值填充到第二个dropdownlist就可以了
#3
http://singlepine.cnblogs.com/articles/265678.html
#4
可以用数据库的当前的值当作过虑条件,
以下是我的winform的程序。你可以参考一下,dropdownlist和combox的使用差不多!!
在数据库中可以考虑用存储过程编写sql查询语句,页面载入的速度快点!
'调用数据绑定类别1的数据
Sub cboxstyle1binding()
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
sql = "select distinct(style1) from tabimgoption "
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style1")
cboxstyle1.DataSource = ds.Tables(0)
cboxstyle1.DisplayMember = "style1"
sqlconn.Close()
sqlconn.Dispose()
End Sub
'调用2数据绑定类别1的数据
Private Sub cboxstyle1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboxstyle1.SelectedIndexChanged
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
Dim style1str As String = cboxstyle1.Text.ToString
sql = "select distinct(style2) as style2 from tabimgoption where style1= '" & style1str & "'"
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style2")
cboxstyle2.DataSource = ds.Tables(0)
cboxstyle2.DisplayMember = "style2"
sqlconn.Close()
sqlconn.Dispose()
End Sub
以下是我的winform的程序。你可以参考一下,dropdownlist和combox的使用差不多!!
在数据库中可以考虑用存储过程编写sql查询语句,页面载入的速度快点!
'调用数据绑定类别1的数据
Sub cboxstyle1binding()
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
sql = "select distinct(style1) from tabimgoption "
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style1")
cboxstyle1.DataSource = ds.Tables(0)
cboxstyle1.DisplayMember = "style1"
sqlconn.Close()
sqlconn.Dispose()
End Sub
'调用2数据绑定类别1的数据
Private Sub cboxstyle1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboxstyle1.SelectedIndexChanged
Dim sql As String
Dim sqlconn As New SqlConnection(strconn)
sqlconn.Open()
Dim style1str As String = cboxstyle1.Text.ToString
sql = "select distinct(style2) as style2 from tabimgoption where style1= '" & style1str & "'"
Dim sqladapt As New SqlDataAdapter(sql, sqlconn)
Dim ds As New DataSet
sqladapt.Fill(ds, "style2")
cboxstyle2.DataSource = ds.Tables(0)
cboxstyle2.DisplayMember = "style2"
sqlconn.Close()
sqlconn.Dispose()
End Sub
#5
在WebForm里时将DropDownList属性设置AutoPostBack=True;回传