Wrox Programmer Forums
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 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 April 18th, 2008, 09:55 PM
Authorized User
Join Date: Apr 2008
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:

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


Old April 18th, 2008, 10:59 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

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

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

Old April 19th, 2008, 02:45 AM
Authorized User
Join Date: Apr 2008
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post

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?


Old April 19th, 2008, 07:16 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

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.Conve rsions.ParseDouble(String Value, NumberFormatInfo NumberFormat) +211
Microsoft.VisualBasic.CompilerServices.Conve rsions.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.



Imar Spaanjaars
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.

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 04:57 AM
Exercise Solution jgrat BOOK: Beginning Access VBA 3 October 18th, 2004 04:13 PM

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