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 July 15th, 2010, 09:28 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default LINQ Chapter 13 DataBind issue

I have some odd behavior. After completting the Try it out Chapter 13 which starts on page 428, when running the Reviews/All.aspx page as suggested at step 8 I get this error:

Only assignment, call, increment, derement, and new object expressions can be used as a statement

in relation to this code:

using (PlanetWroxDataContext myDataContext = newPlanetWroxDataContext())
{
var allReviews = from review in myDataContext.Reviews
where review.Authorized == true
orderby review.CreateDateTime descending
select review;
GridView1.DataSource = allReviews;
GridView1.DataBind();
}

The issue is with 'GridView1.DataBind();' spacifically the GridView1 part of it. I check my code, then check it again. Finally I re-save the page running out of things to try, no luck. I shut down VS and re-open and the issue goes away. very odd! SO I move on through the book. Now the next LINQ try it out starting on page 439 I get exactly the same behavior. This time its the Reviews/AllByGenre.aspx for this code:

protectedvoid Page_Load(object sender, EventArgs e)
{
using (PlanetWroxDataContext myDataContext = newPlanetWroxDataContext())
{
var allGenres = from genre in myDataContext.Genres
orderby genre.Name
selectnew { genre.Name, genre.Reviews };
Repeater1.DataSource = allGenres;
Repeater1.DataBind();
}
}

As the previous issue was its caused by 'Repeater1.DataBind();' specifically the 'Repeater1' part . NOTE inside VS ''Repeater1' is underlined in blue indicating onmouseover the same error as I get when I try to run the page:

Only assignment, call, increment, derement, and new object expressions can be used as a statement

So I close down VS, re-open it and the error goes away. Why would I be getting this behaviour. Am I missing something? Note I am using VS 2010.

TYIA
__________________
Wind is your friend
Matt
 
Old July 18th, 2010, 07:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Matt,

Could it be that the error is actually in a different file or page? What happens when you right-click the site and choose Build Web Site (or Rebuild Web Site) and the double-click the error? Does the error list list the filename with the offending piece of code? And does the page work at run-time?

P.S. When posting code, can you please use the Remove Text Formatting button or paste in Notepad first? Now (because of a bug in this forum) the code gets messed up making it hard to see a potential problem.

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 July 18th, 2010, 06:45 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Hi Imar

Look I guess that must be why. I mean if there isnt a commonly known 'Oh this is why, because......'

That said. I did think of that and Shift + Ctrl + S to save all open docs and then Ctrl + F5 to hopefully get a fresh page. I then closed the browser and tried witha fresh browser. mmmmm very strange. Anyhow Im upto Chapter 13 now, it has not happened again.

I am however having real issues with the Chapter 13 try it out 'Inserting and deleting data with the list view control' I have been through this (and the previous one incase the issue is related) twice now unsuccesfully. I will carefully try this a third time before creating a new post. After looking at the errata page of course
__________________
Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 13 pg 428: Where is the LInq to SQL class? tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 July 2nd, 2009 07:25 AM
GridView Databind issue julius ASP.NET 2.0 Basics 1 March 31st, 2009 11:05 PM
Chapter 13-index.php issue Swilling BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 February 25th, 2009 12:15 AM
LINQ: Chapter 13, the first example cannot be run clark BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 January 15th, 2009 08:41 AM
LINQ Error ? Chapter 13 workidoo BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 22nd, 2008 09:37 AM





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