Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 November 22nd, 2007, 05:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Do you get this error with the original source downloaded from this web site and just the fix I recommended?

In the code you posted I can't find a reason for the error you're getting.....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old November 23rd, 2007, 06:00 AM
Authorized User
 
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar

Thanks for your reply.

I made your fixes to source I obtained from book CD not site download.

So I'll try downloading source from site instead.

Rgds, John

 
Old November 23rd, 2007, 07:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That shouldn't make a difference. The code from the CD is pretty much the same as the code on-line, except for the stuff in the errata section.

I was referring to any customizations you made. Like I said, the code you posted can't generate the error you posted.

Maybe you check your code, set a break point in it and see where it crashes exactly? Once you post the relevant code, it's easier for me to suggest a fix.

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old November 23rd, 2007, 08:39 AM
Authorized User
 
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar

I reinstalled source from CD, made no changes other than your 2 fixes in Products.aspx and Products.aspx.vb but got same result as I originally stated, that is:

I get following error:

  "Unable to cast object of type 'System.Web.UI.LiteralControl' to
   type 'System.Web.UI.WebControls.Button'."

Error occurs in this line(36) of gvProduct_RowCreated Event in Products.aspx.vb:

  Dim myButton As Button = CType(e.Row.Cells(3).Controls(0), Button)

Any other ideas?

Thanks for help so far.

Rgds, John



 
Old November 23rd, 2007, 04:57 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi John,

I think I found the issue.

Initially, the code in the code behind (in gvProduct_RowCreated) to be exact) was responsible for finding the button and adding the onclick handler. The code assumed that the Button was the first control in the cell (which is correct if you use a BoundField.

By converting to a <ItemTemplate>, this is no longer the case, and thus the code crashes when it tries to use the myButton variable.

The fix is simple though; just comment out all code in the gvProduct_RowCreated handler; or better yet: remove the entire handler.

My current working copy of the Customer Support Site had this code commented out as well, from last time I fixed this. Apparently, I forgot to post this information (as I warned in my post, my brain was melting at that time) and the OP never posted a follow up on that.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old November 26th, 2007, 06:11 AM
Authorized User
 
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar

Thanks for explanation and fix - now works okay.

Weird thing is I commented out that event before and it lead to a different error message, though this was with the code i'd already made several other changes to.

I'll now take my time amending the reloaded project.

All the best, John

 
Old November 26th, 2007, 04:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome. Good luck....

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old June 23rd, 2009, 02:58 PM
Registered User
 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default It works with some adjustments

First I would like to say "thank you" to the authors of this book. It has been very educational and usefull.

Second I would like to point out a missing piece in the errata for the book, this code
Code:
 CommandArgument='<%# Eval("Id") %>'
was missing in the errata. Once I figured out what was supposed to be there all is good.

Thanks again
 
Old June 24th, 2009, 03:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi hrdndogs,

You're welcome; good to hear you like the book.

Took me a while to figure out what exactly you were saying. I knew the CommandArgument was in the errata so I didn't understand the problem. Now I see that the "<%# Eval("Id") %>" is missing from the CommandArgument..

I'll have it fixed as soon as possible. Thanks for reporting it.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 24th, 2009, 03:41 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Heuh? I just noticed if you copy and paste the errata, the code *is* there? Try this:

Go here: http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html

Select the text with the CommandArgument in bold, copy it and paste it in Notepad. Do you get Eval("ID") ??

Weird...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error-Object does not support doesn't support this bootsy Classic ASP Basics 1 May 25th, 2008 07:14 PM
Customer Support Site Master Pg. Meta Tags taggiese BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 February 26th, 2007 11:35 PM
Customer Support overdos2 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 November 30th, 2006 04:54 PM
Customer Support - Adding Second Level Category mfoof BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 July 4th, 2006 12:22 AM
Customer table missing? doanhvu BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 June 27th, 2006 12:57 AM





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