我有2个下拉列表,1个标签& 1个文本框。通过sql select语句显示ID和名称
选择“产品类别”@ 1st ddl,2nd ddl显示所有产品类别。
问题是,我怎么可能显示产品类别id @标签,并在加载/选择第二个ddl时显示文本框名称?
我有以下代码:
Public Sub FilterProductCategory()
Dim myConn As New SqlConnection
Dim myCmd As New SqlCommand
Dim dtrReader As SqlDataReader
myConn.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
myCmd = myConn.CreateCommand
myCmd.CommandText = "SELECT product_category_id, product_category_name FROM ProductCategory ORDER BY product_category_name"
Try
myConn.Open()
dtrReader = myCmd.ExecuteReader()
If dtrReader.HasRows Then
DropDownList2.Items.Clear()
DropDownList2.DataSource = dtrReader
DropDownList2.DataValueField = "product_category_name"
DropDownList2.DataBind()
End If
dtrReader.Close()
myConn.Close()
Catch
End Try
End Sub
以上3条建议现在工作正常。现在我的问题是,只有在选择@ ddl2之后,这些更改才会反映出来。 负载时,它没有。目前该标识显示在标签和文本框中。 任何想法? – brainsfrying 2011-12-29 13:26:41