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
|