Error with Shopping cart

Reply

Join Date: May 2006
Posts: 32
Reputation: DATABASE is an unknown quantity at this point 
Solved Threads: 0
DATABASE DATABASE is offline Offline
Light Poster

Error with Shopping cart

 
0
  #1
May 27th, 2008
i am working on Shopping cart

in the AddToCart function
at this line >>> cost1 = Decimal.Parse(ddlProducts.SelectedItem.Value)
there is an error
this is the error message
Input string was not in a correct format.


  1. Sub AddToCart(s As Object, e As EventArgs)
  2. objDT = Session("Cart")
  3. Dim Product = ddlProducts.SelectedItem.Text
  4. Dim blnMatch As Boolean = False
  5.  
  6. For Each objDR In objDT.Rows
  7. If objDR("Product") = Product Then
  8. objDR("Quantity") += txtQuantity.Text
  9. blnMatch = True
  10. Exit For
  11. End If
  12. Next
  13.  
  14. If Not blnMatch Then
  15. objDR = objDT.NewRow
  16. objDR("Quantity") = txtQuantity.Text
  17. objDR("Product") = ddlProducts.SelectedItem.Text
  18.  
  19. Dim cost1
  20. cost1 = Decimal.Parse(ddlProducts.SelectedItem.Value)
  21. MsgBox(cost1)
  22. objDR("Cost") = cost1
  23. objDT.Rows.Add(objDR)
  24.  
  25.  
  26. End If
  27. Session("Cart") = objDT
  28.  
  29. dg.DataSource = objDT
  30. dg.DataBind()
  31.  
  32. lblTotal.Text = "$" & GetItemTotal()
  33. End Sub




need help plz
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 43
Reputation: sebastian3 is an unknown quantity at this point 
Solved Threads: 1
sebastian3 sebastian3 is offline Offline
Light Poster

Re: Error with Shopping cart

 
0
  #2
May 28th, 2008
I think datatype conversion problem.

Try this :

cost1 = Decimal.Parse(Convert.ToString(ddlProducts.SelectedItem.Value))
or cost1 = Decimal.Parse(ddlProducts.SelectedItem.Text)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 431 | Replies: 1
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC