Hi. I'm using vs2008 and vb on my web application. If the user selects an order in a dropdownlist, it populates a product dropdownlist with the products on that paticular order. My dropdownlists are unbound and filled using a reader. for example:
Dim Con As New System.Data.SqlClient.SqlConnection(strConnect)
Con.Open()
strSql = "select t1.ProductID,t2.description from slorder t1 inner join Inproduc t2 " & _
"on t1.productID = t2.ProductID where t1.orderID = '" & strQJB & "' AND T1.ProductID <> 'SPCFRT' order by t1.productID;"
Dim PltCmd As New System.Data.SqlClient.SqlCommand(strSql, Con)
Dim rdr As System.Data.SqlClient.SqlDataReader = PltCmd.ExecuteReader()
' Populate the Control
While rdr.Read()
Dim newListItem As New ListItem()
newListItem.Text = rdr.GetString(0) + " " + rdr.GetString(1)
newListItem.Value = rdr.GetString(0) + " " + rdr.GetString(1)
dropProd1.Items.Add(newListItem)
End While
rdr.Close()
Con.Close()
If the user selects the wrong order and goes back and selects the correct one, my products dropdownlist is showing all of the products from both orders, not just the correct ones. How do I clear out the product dropdown before loading in the correct products?
Thanks
Cathy
Dim Con As New System.Data.SqlClient.SqlConnection(strConnect)
Con.Open()
strSql = "select t1.ProductID,t2.description from slorder t1 inner join Inproduc t2 " & _
"on t1.productID = t2.ProductID where t1.orderID = '" & strQJB & "' AND T1.ProductID <> 'SPCFRT' order by t1.productID;"
Dim PltCmd As New System.Data.SqlClient.SqlCommand(strSql, Con)
Dim rdr As System.Data.SqlClient.SqlDataReader = PltCmd.ExecuteReader()
' Populate the Control
While rdr.Read()
Dim newListItem As New ListItem()
newListItem.Text = rdr.GetString(0) + " " + rdr.GetString(1)
newListItem.Value = rdr.GetString(0) + " " + rdr.GetString(1)
dropProd1.Items.Add(newListItem)
End While
rdr.Close()
Con.Close()
If the user selects the wrong order and goes back and selects the correct one, my products dropdownlist is showing all of the products from both orders, not just the correct ones. How do I clear out the product dropdown before loading in the correct products?
Thanks
Cathy