Input String was not a correct format
Hi, I have modify the code and found that the code on page 501 have "Input String was not a correct format" error when running the shopping cart page.:(
below is the code in red color, my datbase Product table price field is money which same as book sample.
Partial Class ShopItem
Inherits System.Web.UI.Page
Protected Sub btnAddToCart_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnAddToCart.Click
Dim Price As Double = Double.Parse(CType(DataList1.Controls(0).FindContr ol("PriceLabel"), Label).Text)
Dim ProductName As String = CType(DataList1.Controls(0).FindControl("NameLabel "), Label).Text
Dim Imagelink As String = CType(DataList1.Controls(0).FindControl("Imagelink "), Label).Text
Dim ProductID As Integer = CInt(Request.QueryString("ProductID"))
' create the cart if it doesn't already exist
If Profile.Cart Is Nothing Then
Profile.Cart = New SW.Commerce.SWShoppingCart()
End If
' insert the item
' if the item already exists in the cart, 1 will be added to the quantity
Profile.Cart.Insert(ProductID, Price, 1, ProductName, Imagelink)
' return back to the main shop page
Server.Transfer("default.aspx")
End Sub
End Class
|