Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2006, 09:54 AM
Registered User
 
Join Date: Nov 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch.13 Builing a Shopping Cart

I´m having trouble with the Add to Cart Button. I have created a button and clicked and added the code supplied by the book.

I have done exactly as in the end files for this chapter. The code looks exactly like the end file yet it is not working for me when the button is clicked.

The message points at the Double.Parse on the first line of the code and reads "make sure the arguments to this method have valid values"

Here´s the copde I´m referring to below:

Protected Sub btnAddToCart_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim Price As String = Double.Parse(CType(DataList1.Controls(0).FindContr ol("PriceLabel"), Label).Text) Dim ProductName As String = CType(DataList1.Controls(0).FindControl("NameLabel "), Label).Text
        Dim PictureURL As String = CType(DataList1.Controls(0).FindControl("PictureUr lLabel"), Label).Text
        Dim ProductID As Integer = CInt(Request.QueryString("ProductID"))
        If Profile.Cart Is Nothing Then
            Profile.Cart = New Wrox.Commerce.WroxShoppingCart()
        End If
        Profile.Cart.Insert(ProductID, Price, 1, ProductName, PictureURL)
        Server.Transfer("WroxShop.aspx")



    End Sub


I´d be very grateful for any help with this
 
Old December 15th, 2006, 02:34 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Should be "Dim Price As Double"
instead of "Dim Price As String"
 
Old December 30th, 2006, 02:38 PM
Registered User
 
Join Date: Nov 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried this but it didn't work.

Any other suggestions?

 
Old February 7th, 2007, 10:11 AM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Change it from:

Dim Price As String = Double.Parse(CType(DataList1.Controls(0).FindContr ol("PriceLabel"), Label).Text)

to:

Dim Price As Double = Double.Parse(CType(DataList1.FindControl("PriceLab el"), Label).Text)

The extra layer of "Controls(0)" gets it lost. You can do the same for the other variables in that procedure.

Good luck.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 Shopping Cart michaelcode BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 9 January 25th, 2010 03:50 AM
Chapter 13: shopping cart problem mysecondlove BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 April 9th, 2008 06:48 PM
Chapter 13 Shopping Cart disappears after login bwinklesky BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 June 14th, 2007 12:34 PM
Ch 10: Problem with shopping cart example code Storm BOOK: Beginning ASP.NET 1.0 0 October 11th, 2004 03:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.