Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 12th, 2006, 09:54 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old December 15th, 2006, 02:34 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Should be "Dim Price As Double"
instead of "Dim Price As String"
Reply With Quote
  #3 (permalink)  
Old December 30th, 2006, 02:38 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried this but it didn't work.

Any other suggestions?

Reply With Quote
  #4 (permalink)  
Old February 7th, 2007, 10:11 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07: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 01:34 PM
Ch 10: Problem with shopping cart example code Storm BOOK: Beginning ASP.NET 1.0 0 October 11th, 2004 04:24 PM



All times are GMT -4. The time now is 12:15 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.