Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to display Foreign-Key Name fields in edit mode of data contro

Reply
Thread Tools

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

 
 
=?Utf-8?B?Sm9uYXRoYW4gTC4=?=
Guest
Posts: n/a
 
      08-26-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can show fields in edit mode but not update it- I don't want it in my parameters rote ASP .Net 0 09-05-2008 12:58 AM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Would like to load a datagrid already in edit mode instead of having the user click the edit button Frank Kurka ASP .Net Datagrid Control 8 04-29-2005 09:33 AM
Q: How to use DataGrid in Edit Mode -- with more fields than shown? Sky ASP .Net 2 01-29-2004 11:02 AM



Advertisments