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 March 29th, 2013, 04:45 PM
Authorized User
Join Date: Feb 2013
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Default Best Practice for handling the display of foreign key relationships in a Listview


What is your recommendation for the best way to display the text-equivalent value of a foreign key field in a databound Listview (or any tabular presentation). I am using a DropDownList in the Edit and Insert templates but it really bloats the HTML if you use a DropDownList in the Item and AlternatingItem templates. I could use a View but that means writing Stored Procedures for each Insert, Update & Delete. A data-bindable label or textbox would be perfect - provide it with the key value and it would display the text value. Other than that - how do handle these situations?


Old March 30th, 2013, 09:53 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

If you're using a SqlDataSource, you can specifiy a query for Select that contains an INNER JOIN on the other table. That way, you can retrieve both the ID and Name of the related item. Inserts and Updates would still use the Id, coming from the DropDownList.

Hope this helps,

Imar Spaanjaars
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!

Similar Threads
Thread Thread Starter Forum Replies Last Post
best practice on managing private key yangguo BOOK: Beginning Cryptography with Java 1 February 10th, 2010 03:36 AM
Foreign key not updating with Primary key xavier1945 BOOK: Access 2003 VBA Programmer's Reference 2 July 4th, 2007 09:48 PM
Handling special/foreign characters ... mussitsch Classic ASP Professional 1 October 10th, 2006 02:17 PM
FOREIGN KEY and PRIMARY KEY Constraints junemo Oracle 10 June 15th, 2004 01:00 AM
Foreign Key Problem re_anu SQL Server 2000 1 September 26th, 2003 10:58 AM

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