I know from the title this seems simple however there is a twist. I have a page that a user fills out to submit feedback on products. To keep data clean, I let them select the product, type and size based on dropdown lists, but also want to make it so if they type in the barcode, the values for the Product, Type and Size are looked up and populated on the form for them to see it before submitting the form. The form has several textboxes and dropdown lists that update using SQLDataSource connections. The problem that I'm running ito is the following:
I have two Input Fields:
Barcode (textbox) and ProductCode (dropdownlist)
I have Two other fields:
ProductSize, ProductCategory (both dropdownlists)
Here is what I'm doing.
If the user clicks the ProductCode field, he can pick a value and the ProductSize and ProductCategory dropdowns refresh and display the appropriate values. Then the user can pick his selection of these two fields and he's on his merry way to submit the form.
However, I'd like to set it up so that if the user enters a value into the Barcode box, upon updating the field, the ProductCode, ProductSize and ProductCategory fields all get values assigned to them based on a SQL lookup to the product database.
Since I have SQLDataSource connections to the three dropdownlists, I don't think I can assign another one to them to pull values based on the Barcode and not the ProductCode. What I was thinking of is to create code in the BarCode textbox textchanged event to pull the values from the SQL table and then assign them to the listboxes. I think it's fairly simple however I'm not that greate with VB.Net and here is what I have, but I dont' know how to assigne it to a value so then I can assign it to the dropdownlists:
ProtectedSub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim complaintDataSource As New SqlDataSource()complaintDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("complaintConnectionString2").ToString()
complaintDataSource.SelectCommandType = SqlDataSourceCommandType.Text
complaintDataSource.SelectCommand ="Select pclass from products where ([barcode] = @barcode)"
If I just leave the "ComplaintDataSource.Select()" line like that, it tells me I'm missing arguments. What I'd like to find out is how can I evaluate the selection and assign it to a string value that later I can assign to one if the dropdownlists.
Sorry to be so long, but this seems to be simple in concept but I'm new to this whole thing and the MSDN help seems to confuse me more than help me.
I'm basing all this code on my submit button that has the following code in it to submit the form:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim complaintDataSource As New SqlDataSource()complaintDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("complaintConnectionString2").ToString()
complaintDataSource.InsertCommandType = SqlDataSourceCommandType.Text
complaintDataSource.InsertCommand ="INSERT INTO feedback (LName, FName, Address1, City, State, Zip, IPAddress, Entered, EmailAddress, Comment, Product, SubProduct, Code) VALUES (@Lname, @FName, @Address1, @City, @State, @Zip, @IPAddress, @Entered, @EmailAddress, @Comment, @Product, @SubProduct, @Code)"
complaintDataSource.InsertParameters.Add("FName", FName.Text)complaintDataSource.InsertParameters.Add("Address1", Address1.Text)
complaintDataSource.InsertParameters.Add("City", City.Text)complaintDataSource.InsertParameters.Add("State", State.Text)
complaintDataSource.InsertParameters.Add("Zip", Zip.Text)complaintDataSource.InsertParameters.Add("IPAddress", Request.UserHostAddress.ToString())
complaintDataSource.InsertParameters.Add("Entered", DateTime.Now)complaintDataSource.InsertParameters.Add("EmailAddress", EmailAddress.Text)
complaintDataSource.InsertParameters.Add("Comment", Comment.Text)complaintDataSource.InsertParameters.Add("Product", Product.text)
complaintDataSource.InsertParameters.Add("SubProduct", SubProduct.Text)complaintDataSource.InsertParameters.Add("Code", Code.Text)
Dim rowsAffected As Integer = 0
rowsAffected = complaintDataSource.Insert()
Catch ex As ExceptionServer.Transfer("ReturnPages\EntryError.aspx") Finally
If rowsAffected <> 1 Then
End If End Sub
Thanks for any feedback.