Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : 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 July 14th, 2011, 11:23 AM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How does LINQ know to display the title of a review??

Hi,

I'm currently in Chapter 14 "Linq and the ADO.Net Entity Framework" and am on the Try It out "Working with Queries and anonymous types".
The try out uses a repeater and a bulleted list to display a Genre and each review associated with that Genre using this C# / ASP.Net code

<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<h3><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Name") %>'></asp:Literal></h3>
<asp:BulletedList ID="ReviewList" runat="server" DataSource='<%# Eval("Reviews") %>'
DataTextField="Title" DisplayMode="Text">
</asp:BulletedList>
</ItemTemplate>
</asp:Repeater>

using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
{
var allGenres = from genre in myEntities.Genres
orderby genre.Name
select new {genre.Name, genre.Reviews};
Repeater1.DataSource = allGenres;
Repeater1.DataBind();
}

The bit in bold I don't understand, how does the bulleted list know to display the title of each review and not another column from the reviews table??

Thanks
Dale


Apologies, I've found the answer. Wasn't looking hard enough....

<asp:BulletedList ID="ReviewList" runat="server" DataSource='<%# Eval("Reviews") %>'
DataTextField="Title" DisplayMode="Text">

Nothing to see here.

Last edited by DCT1984; July 14th, 2011 at 11:33 AM.. Reason: Found the answer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Word doc's file path in the title bar but doc title only in Word taskbr item? numov_40 Word VBA 2 May 15th, 2011 04:06 AM
Another Review ttschopp BOOK: Joomla! Start to Finish: How to Plan, Execute, and Maintain Your Web Site 1 August 28th, 2010 08:49 AM
Using LINQ a Listview to display an image digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 19 May 1st, 2010 12:23 PM
cannot get title to display correctly ruairi ASP.NET 2.0 Basics 7 June 19th, 2007 08:28 AM





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