Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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.
0
ashp87
Asked:
ashp87
  • 4
1 Solution
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
informaniacCommented:
Have u set the datatype of the range validator? By default it is string. u will need to change it.
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now