Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB 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 March 31st, 2014, 01:56 PM
Authorized User
 
Join Date: Mar 2014
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default LINQ - How to get Single() review

Hi Imar,

First, thank you for answering all my questions.

I'm having a problem displaying a single review from the Review table.

I'm trying like this:

Code:
using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
        {
            var review37 = (from r in myEntities.Reviews
                                  where r.Id == 37
                                  select r).Single();
        }
but it's not working. It's showing this error on the browser:

Exception Details: System.ArgumentException: An invalid data source is being used for Repeater2. A valid data source must implement either IListSource or IEnumerable.
 
Old March 31st, 2014, 05:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can't use a list control with a single instance returned from a query. So either drop the Single() statement (so you still get a collection, but with only one object in it) or use the a different control such as a Label (or multiple labels) to display the object. The AddEditReviewHandCoded page shows how that works.

Hope this helps,

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!
The Following User Says Thank You to Imar For This Useful Post:
southside123 (April 1st, 2014)





Similar Threads
Thread Thread Starter Forum Replies Last Post
single review for every genre sophia BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 24th, 2012 06:46 PM
Single Review assigned to multiple Genres sophia BOOK: Beginning ASP.NET 4 : in C# and VB 12 January 17th, 2012 07:32 AM
LINQ to EF and LINQ to SQL sophia BOOK: Beginning ASP.NET 4 : in C# and VB 1 October 19th, 2011 12:16 PM
How does LINQ know to display the title of a review?? DCT1984 BOOK: Beginning ASP.NET 4 : in C# and VB 0 July 14th, 2011 11:23 AM
Retrieving a single value from a single column in a single row? Ron Howerton LINQ 2 May 17th, 2011 08:46 AM





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