-
i have 2 dropdown lists, 1 label & 1 textbox.
-
on selection of ‘product categories’ @ 1st ddl, 2nd ddl displays all product categories.
-
question is, how may i display the product category id @ the label, and name @ the textbox, on load/selection of 2nd ddl?
-
i have the following code:
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
just set this:
so when you try dropdownlist2.selectedvalue then you will get id and when u try dropdownlist2.selecteditem.text then it will give you product category name ..
hope it will solve your problem