 |
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
|
|
|
|
|

November 22nd, 2007, 05:17 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

November 23rd, 2007, 06:00 AM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 23rd, 2007, 07:29 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

November 23rd, 2007, 08:39 AM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 23rd, 2007, 04:57 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

November 26th, 2007, 06:11 AM
|
|
Authorized User
|
|
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 23rd, 2009, 02:58 PM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 24th, 2009, 03:39 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 24th, 2009, 03:41 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |