ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 CoverYourASP --> Displaying foreign keys as list boxes

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
111 active users
1022 visitors today
1588 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2008 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

When I originally wrote my online database administration pages I went for the simple approach. As a consequence, I just displayed the values of the fields as they appeared in the tables. Here's an example of how that looked:

Action|CarID|MakeID|Model|ColorID
Edit
Delete
12C3500 Dooley1
Edit
Delete
27Town and Country8
Edit
Delete
33Grand Am1

The CarID is an auto-number primary key, and hence is just displayed as-is - no problem there since you cannot edit that anyway. But the MakeID and ColorID fields are primary keys from other tables - CarMakes and CarColors.

Using the Relationships tool in Access I had already linked the fields to the relevant table. This creates "foreign keys" which we have access to from our ASP pages.

The improvement I recently made takes advantage of this data, and creates list boxes of the linked tables for display or editing. The list box contents are stored in Application variables for efficiency - I'll show you how all this is done in this article. The results are shown below - a huge improvement!

Action|CarID|MakeID|Model|ColorID
Edit
Delete
1C3500 Dooley
Edit
Delete
2Town and Country
Edit
Delete
3Grand Am

Part 2: Reading the foreign keys...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!


New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!