How to display Foreign-Key Name fields in edit mode of data contro

G

Guest

I've got a relatively simple scenario that I haven't been able to solve in
ASP 2.0.

Let's assume I have a simple foreign key relationship as demonstrated below:

------------------- -----------------------------
| States | | Customers |
------------------- ----------------------------
| ID | Name | | ID | Name | Location |
-------------------- -----------------------------
| 1 | Alabama | | 1 | Bob | 3 |
| 2 | Alaska | | 2 | Joe | 2 |
| 3 | Arizona | | 3 | Jill | 1 |
| n | ... | | n | .... | ... |
-------------------- -----------------------------

Now, let's assume I want a webform to display (or allow editing) a list of
customers with a DataGrid or similar control.

I have NOT been able to figure out a way in ASP 2.0 to have the name field
in the foreign key table to display the state name.
For viewing, this is easily overcome by designing a query that contains
performs the appropriate join and then display that column... but what if I
want to edit?

In edit mode, I would still like to display the state name (in a
DropDownList of all states) and use that in performing the edit/update. I
can't find a way to do this.

In ASP 1.1 this way relatively easy - You could use a DataList and bind the
List to an SQLDataAdapter containing the "Customers" table and have a second
SQLDataAdapter containing the States table. For the DropDownList in edit
mode, you could override the default binding and bind the DataTextField and
DataValueField properties seperately to the full list of states in the second
SQLDataAdapter.

This should be an incredibly common and simple task - displaying a lookup
for a foreign key - but I haven't gotten it to work vis-a-vis editing data,
and this has been embarassing.

Any help or suggested links are appreciated.

- Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top