This is a migrated thread and some comments may be shown as answers.

Displaying Lookup Table Data Values

3 Answers 327 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 20 Apr 2012, 09:11 AM
Assume I have the following two tables:

Table 1 (Customer) has the following fields:
1) Customer ID
2) First Name
3) Last Name
4) Street Address
5) City FK

Table 2 (City) has the following fields:
1) City PK
2) City

Table 2 is a look-up table that consists of city names.  City PK if the primary key field for the City table.  These primary key values appear as foreign key values in the City FK field of the Customer table.

I want to add a grid view to a form which shows all of the data in the Customer table.  Instead of showing the foreign key values in the City FK field, I want to show the actual city name which corresponds to the foreign key value stored in this field.  How can I do this with the grid view control? 

I had placed a grid view on a form and had attached a data set to this control, but the the City column is showing foreign key values for the city instead of the city name.  This is what I don't want the grid view to show.  How can I resolve this problem?


Thanks.


3 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 20 Apr 2012, 09:32 AM
Hello, 

This isn't really a Telerik question as it's down to the datasource that you wish to bind to your grid. However, there are a number of ways. I'd suggest either looking at dataset relations, or simply creating a stored procedure that returns the joined data. 

Hope this helps
Richard
0
James
Top achievements
Rank 1
answered on 20 Apr 2012, 07:30 PM
I looked at the relations tutorial and help documentation relating to this topic.  They all talk about creating a grid view with a master-detail relationship (i.e. parent-child relationship).  I understand this approach but it's not what I want to do.  I could easily construct a SQL statement joining the two tables but I would not be able to edit the data in the grid view when it displays the data.  Could you please direct me to an help/documentation file that would show me how to accomplish what I want to do or attach a sample file to illustrate it?


Thanks.





0
Accepted
James
Top achievements
Rank 1
answered on 20 Apr 2012, 08:20 PM
I found the solution in the combo box editor tutorial.

Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
James
Top achievements
Rank 1
Share this question
or