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 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 April 18th, 2008, 09:55 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 13 Exercise 3 solution

Hi Imar,

On page 678, exercise 3 solution, you wrote:

Code:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl= '<%# "PictureDetails.aspx?Id=" + Eval("Id") %>'>
I ran it but it says "no data returned" for all the albums.
When I changed the "+" sign to "&" sign of the code, it works. BTW, I am using VB coding. Could it be your code is for C#?

Thanks.

Reply With Quote
  #2 (permalink)  
Old April 18th, 2008, 10:59 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes, you are correct. In the example solution the markup is in C#.

My apologies, I should have caught that during technical review.

-Peter
peterlanoie.blog
Reply With Quote
  #3 (permalink)  
Old April 19th, 2008, 02:45 AM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Peter,

That's strange. I tried out another "Try It Out" on page 507 today and I used "+" instead of "&" and it works fine.

What is stranger is the message it returns. What did it give a "no data returned" in the web browser when it should have given me an error in VWD?

Thanks.

Reply With Quote
  #4 (permalink)  
Old April 19th, 2008, 07:16 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Hi there,

You probably don't get "No data returned", but due to an error the page is not updated and still shows the old "no data" message. Just for fun, try this:

1. Restore the + again in the code

2. Remove the <UpdatePanel> and <ContentTemplate> or turn on JavaScript debugging through Tools | Internet Options | Advanced in IE.

3. Rerun the page. Now you get an error like this:

Line: 5
Error: Sys.WebForms.PageRequestManagerServerErrorExceptio n: Conversion from string "PictureDetails.aspx?Id=" to type 'Double' is not valid.

Alternatively you may get:

[FormatException: Input string was not in a correct format.]
   Microsoft.VisualBasic.CompilerServices.Conversi ons.ParseDouble(String Value, NumberFormatInfo NumberFormat) +211
   Microsoft.VisualBasic.CompilerServices.Conversi ons.ToDouble(String Value, NumberFormatInfo NumberFormat) +74

So, the conversion failed right away. Due to the Ajax UpdatePanel, you probably never got the error in the browser.

The Tio in Chapter 14, page 507 works because the Id is converted to a String:

NavigateUrl='<%# "ViewDetails.aspx?ReviewId=" + Eval("Id").ToString() %>'

In this example, both ends of the assignment operations are strings, so concatenation works as expected. In the problem you posted, the code tries to "add up" the string and the Id which obviously fails.

There are two ways to fix it:

1. Use &. This tells the VB compiler to concatenate the values rather than try to add them to each other.

2. Use ToString() on Eval("Id"). This removes the ambiguity between the two sides of the assignment, so again the compiler knows it should concatenate, rather than add the two values to each other.

Thanks for catching and reporting this; I'll file an errata for it.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
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
My solution to exercise 6, on ch.2 - help rjm BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 July 28th, 2010 05:50 PM
Solution to exercise 7, Chapter 2 Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 May 28th, 2006 04:28 AM
exercise solution uddessjava Java Basics 1 December 29th, 2005 03:57 AM
Exercise Solution jgrat BOOK: Beginning Access VBA 3 October 18th, 2004 04:13 PM



All times are GMT -4. The time now is 07:39 AM.


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