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 February 26th, 2010, 08:06 PM
Authorized User
 
Join Date: Aug 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Querying across tables using Listview

I know you can query across two tables using a template field but can you do that in a Listview?
 
Old February 27th, 2010, 06:30 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 there,

I am not sure what you're asking. You don't "query" with a TemplateField or a ListView. You only display data with them. Querying is typically done with a DataSource control or by setting the DataSource property. Queries used by these controls can use multiple tables and then a ListView or other data-bound control can display whatever you throw at it.

So, can you elaborate a bit about what you're trying to accomplish or what you're asking exactly?

Cheers,

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 February 27th, 2010, 10:29 PM
Authorized User
 
Join Date: Aug 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Actually I'm quite lost.

In the GridView, I remembered being able to use a template field and the eval statement to get data related to the original table I brought up; so with a Category table with a Product table linked to it using a foreign key I can use the foreign key to get data from the Product table (eval - catID.ProductName).

So I use Linq to capture all the fields (if I have my jargon right) from one table and then use Gridview to access a related table.

I know I was able to get to related tables in the Gridview but can't pull it off now. I need to figure out how that happened. Too bad I didn't keep an example.
 
Old February 28th, 2010, 05:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can do the same in an ItemTemplate in the ListView. The ItemTemplate is like one big TemplateField.

So something like this inside the ItemTemplate would work:

<asp:Label ID="Label1" Text='<%# Eval("SomeColumn").ToString() + Eval("SomeOtherColumn").ToString() %>' runat="server"></asp:Label>

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!
 
Old February 28th, 2010, 01:23 PM
Authorized User
 
Join Date: Aug 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sweet. I thought it must capable of doing this - just couldn't find anything on it - looked all over the internet and in several books. Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
schema querying? whelanj XSLT 2 February 2nd, 2010 07:12 PM
Querying from 2 databases rajesh_css Oracle 3 November 18th, 2009 12:17 AM
Error querying LDAP bala24 General .NET 0 March 7th, 2007 10:08 PM
Querying Recordset with a Loop rabu Access VBA 10 December 14th, 2005 04:49 PM





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