p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Best Practice for handling the display of foreign key relationships in a Listview (http://p2p.wrox.com/showthread.php?t=89729)

rah132 March 29th, 2013 04:45 PM

Best Practice for handling the display of foreign key relationships in a Listview
 
Imar:

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?

Thanks,

Robin

Imar March 30th, 2013 09:53 AM

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


All times are GMT -4. The time now is 01:35 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.