Q: DataGrid Display

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G .Net

    #1

    Q: DataGrid Display

    Hi

    I have a question regarding displaying a foreign key in a DataGrid. To
    explain my question, consider the following:

    Suppose I have two tables A and B. Table A has the following structure:

    UID_A ' Primary key of A
    FK_B ' Foreign key to table B i.e. UID_B

    and table B has the following structure:

    UID_B ' Primary key of B
    Name ' List of names e.g. John, Mark, William

    If I set a DataSource of a DataGrid to be A, then I get a grid with values
    such as:

    2 7
    3 8
    4 15
    5 7

    etc.

    What I would like to display is the following:

    2 John
    3 Robert
    4 Bill
    5 John

    That is, I want to display the Name field instead of the FK_B value (these
    are related as shown above).

    Now, in the past, I have been able to do this by creating a new column in A,
    iterating through all the rows and placing the B "Name" in the right place.

    This works BUT I'm sure there must be a simpler, more elegant solution???

    Thanks in advance

    Geoff





Working...