Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to clear unbound dropdownlist. 1

Status
Not open for further replies.

MzKitty

Programmer
Oct 28, 2003
254
0
0
US
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
 
Thank You!!! I've tried dropdownlist.clear() and it didn't work. You are great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top