473,411 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Displaying foreign key data

I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control when I
want to prevent editing (simply displaying in the display template of a
datalist or detailview control, for example). I've not been able to
find a way to edit the disabled color of the dropdown list, so it
appears very washed out - just not a good look and doesn't make much
sense to the user.

Is there a way to bind a text box to the description field in a lookup
table? If I'm showing a list of orders, I really don't want to display
the surrogate key value to denote the customer. I would rather display
the customer's name from the Customers table.

Rich

Jul 10 '06 #1
3 2190
Make a join in the query when you are fetching the data.

Example:

select a.this, a.that, c.CompanyName
from Article a
inner join Company c on c.CompanyId = a.CompanyId

Richard Carpenter wrote:
I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control when I
want to prevent editing (simply displaying in the display template of a
datalist or detailview control, for example). I've not been able to
find a way to edit the disabled color of the dropdown list, so it
appears very washed out - just not a good look and doesn't make much
sense to the user.

Is there a way to bind a text box to the description field in a lookup
table? If I'm showing a list of orders, I really don't want to display
the surrogate key value to denote the customer. I would rather display
the customer's name from the Customers table.

Rich
Jul 10 '06 #2
Well, I had considered that, but does that cause a problem in, for
example, a formview control? If I bind a textbox to the CompanyName in
the itemview template and a dropdown list control to the CompanyID in
the edit and insert templates, what will I need to do to ensure that
the itemview template displays the correct value after an edit or
insert? Anything?

Rich

Göran Andersson wrote:
Make a join in the query when you are fetching the data.

Example:

select a.this, a.that, c.CompanyName
from Article a
inner join Company c on c.CompanyId = a.CompanyId

Richard Carpenter wrote:
I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control when I
want to prevent editing (simply displaying in the display template of a
datalist or detailview control, for example). I've not been able to
find a way to edit the disabled color of the dropdown list, so it
appears very washed out - just not a good look and doesn't make much
sense to the user.

Is there a way to bind a text box to the description field in a lookup
table? If I'm showing a list of orders, I really don't want to display
the surrogate key value to denote the customer. I would rather display
the customer's name from the Customers table.

Rich
Jul 10 '06 #3
Well, I was thinking I'd get an answer to this question and understand
what I was in for before changing too much of the code, but I decided
to bite the bullet and just try it. I was pleasantly surprised to find
that when changes are made to a foreign key field using a dropdown list
in the edititem template of my formview control, they are, in fact,
reflected in the itemview template textbox. That tells me that the data
is re-queried when the changes are saved. This is a good thing in that
respect.

The downside, for my application anyway, is that also means that child
records that are displayed in a grid on the same page will also be
written to the database upon saving. How might I roll back the addition
of new child records in the event the user cancels the edit operation
on the parent?

For instance, if a user clicks the New button in my formview control to
add a new parent record and in the process adds a couple of child
records, then decides to cancel the insert process on the parent, what
happens with the newly-created child records? How can I avoid those
records being written to the database until the parent record is saved?

I have another post dedicated to this question. Answers may be more
appropriately directed there.

Thanks!
Rich

Richard Carpenter wrote:
Well, I had considered that, but does that cause a problem in, for
example, a formview control? If I bind a textbox to the CompanyName in
the itemview template and a dropdown list control to the CompanyID in
the edit and insert templates, what will I need to do to ensure that
the itemview template displays the correct value after an edit or
insert? Anything?

Rich

Göran Andersson wrote:
Make a join in the query when you are fetching the data.

Example:

select a.this, a.that, c.CompanyName
from Article a
inner join Company c on c.CompanyId = a.CompanyId

Richard Carpenter wrote:
I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control when I
want to prevent editing (simply displaying in the display template ofa
datalist or detailview control, for example). I've not been able to
find a way to edit the disabled color of the dropdown list, so it
appears very washed out - just not a good look and doesn't make much
sense to the user.
>
Is there a way to bind a text box to the description field in a lookup
table? If I'm showing a list of orders, I really don't want to display
the surrogate key value to denote the customer. I would rather display
the customer's name from the Customers table.

Rich
>
Jul 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
0
by: Johann Blake | last post by:
I have a dataset that I bind to two different datagrids. The dataset contains 2 tables. One is the main table used to store what I call session data which includes a Country field where the ID of a...
0
by: Nightcrawler | last post by:
Dear Group, I went ahead and used the wizards to create a dataaccesslayer of my database. I checked all my tables and in matter of a few seconds all my tables and relations appeard in VS2005. I...
1
by: kamkoum | last post by:
Hello, I am using readxml to retrieve data from an xml file to a dataset. m xml file has hierarchical data (2 levels) so the dataset will contain tables. My question : I need to display...
0
by: latin & geek via DotNetMonster.com | last post by:
hi! ok, im working on a database application. ive successfully managed to establish a relationship between two tables and display them on a datagrid, edit and add new records to them. now i...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
0
by: anjachow | last post by:
The system generated email that are automatically sent displaying well in any web-based mail systems (yahoo, msn, etc...). The foreign characters (vowels with accents and the ń) aren't displaying...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
5
by: Harlequin | last post by:
Hi there, I'm something of a newcomer to MS Access so it's more than likely that my question is extremely elementary. I have a form whose record source is a single table in my database. It's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.