我的页面上有两个dropdownlist,pbtype和pstype分别是两个dropdownlist的id,用来选择大小类商品进行查询的.pbtype是一个大类商品,pstype是一个小类商品,下面是我的语句.只显示大类商品,但不显示小类商品.
Sub pbtypelist()
Dim strsql As String = "select * from pbtypes"
Dim cmd As New OleDbCommand(strsql, conn)
Dim adp As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
adp.Fill(ds, "pbtypes")
pbtype.DataSource = ds
pbtype.DataTextField = "ptypename"
pbtype.DataValueField = "ptypeid"
pbtype.DataBind()
End Sub
Sub pbtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbtype.SelectedIndexChanged
Dim str As String = pbtype.SelectedValue
Dim strsql As String = "select * from pstypes where pbtypeid='" & str & "'"
Dim cmd As New OleDbCommand(strsql, conn)
Dim adp As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
adp.Fill(ds, "pstypes")
pstype.DataSource = ds
pstype.DataTextField = "pstypename"
pstype.DataValueField = "pstypeid"
pstype.DataBind()
End Sub
[此贴子已经被作者于2007-3-20 11:50:51编辑过]