Trouble with Range Validator

I have a range field validator that checks a quantity textbox for a product before its added to a shopping cart to be between 1 and 10. It works the first time but when the user trys to add more of the same product and enters any number other than 1, even if its in the range, it gives the error.
LVL 1
ashp87Asked:
Who is Participating?
 
Obadiah ChristopherConnect With a Mentor Commented:
Have u set the datatype of the range validator? By default it is string. u will need to change it.
0
 
tiagosalgadoCommented:
Can you show some code please? Its better to detect some error.
0
 
ashp87Author Commented:
this is in the page load, the quantity is required before someone can add a item to the cart:
    Protected Sub btnYes_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnYes.Click
        objDT = Session("Cart")
        Dim Product = lbResults.SelectedItem.Text
        Dim blnMatch As Boolean = False

        For Each Me.objDR In objDT.Rows
            If objDR("Product") = lbResults.SelectedItem.Text Then
                objDR("Quantity") += txtQuantity.Text
                blnMatch = True
                Exit For
            End If
        Next

        If Not blnMatch Then
            objDR = objDT.NewRow
            objDR("Quantity") = txtQuantity.Text
            objDR("Product") = Product
            objDR("Cost") = Decimal.Parse(20)
            objDT.Rows.Add(objDR)
        End If
        Session("Cart") = objDT

        dg.DataSource = objDT
        dg.DataBind()

        Session("Total") = GetItemTotal()
        lblTotal.Text = "$" & GetItemTotal()
    End Sub
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
ashp87Author Commented:
i made a mistake on the post above its not in the page load, i changed teh code i was pasting and i forgot to delete that comment
0
 
ashp87Author Commented:
apparently, it doesnt matter what happens, the first time I click add to cart, the next time i try to add to cart, even if the value is in range, it will come up saying its not in range.
0
 
ashp87Author Commented:
the thing was, in the properties it was set , but when i manually set it in the code, it stopped giving me problems....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.