Contact me if you'd
like to advertise
in this prime spot
 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
34 active users
3242 visitors today
4815 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2009 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


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...