I'm using vs2008 and am loading product dropdownlists when a user selects an order to use on a new ticket. I am loading the dropdownlists with the code below:
Dim Con As New System.Data.SqlClient.SqlConnection(strConnect)
Con.Open()
Try
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)
dropProd2.Items.Add(newListItem)
dropProd3.Items.Add(newListItem)
dropProd4.Items.Add(newListItem)
dropProd5.Items.Add(newListItem)
dropProd6.Items.Add(newListItem)
dropProd7.Items.Add(newListItem)
dropProd8.Items.Add(newListItem)
dropProd9.Items.Add(newListItem)
dropProd10.Items.Add(newListItem)
End While
rdr.Close()
Con.Close()
My problem is when the user selects the wrong order and they go back and select the correct one, the products for both orders show on the dropdownlists. I need to clear the first order's products out before I load in the next orders. I have tried:
dropProd1.Items.Clear()
but it doesn't get rid of the products.
Thanks
Cathy
Dim Con As New System.Data.SqlClient.SqlConnection(strConnect)
Con.Open()
Try
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)
dropProd2.Items.Add(newListItem)
dropProd3.Items.Add(newListItem)
dropProd4.Items.Add(newListItem)
dropProd5.Items.Add(newListItem)
dropProd6.Items.Add(newListItem)
dropProd7.Items.Add(newListItem)
dropProd8.Items.Add(newListItem)
dropProd9.Items.Add(newListItem)
dropProd10.Items.Add(newListItem)
End While
rdr.Close()
Con.Close()
My problem is when the user selects the wrong order and they go back and select the correct one, the products for both orders show on the dropdownlists. I need to clear the first order's products out before I load in the next orders. I have tried:
dropProd1.Items.Clear()
but it doesn't get rid of the products.
Thanks
Cathy