views:

490

answers:

4

I have very simple form along with two database tables.

In this form is a ComboBox, which reads the first table tblProjects. It displays a "Project Name" to the user and when selected, filters a DataGridView, which reads its data from the second table: tblData.

tblData does not contain "Project Name" but instead a Guid that both tables share. Each project has a unique Guid, ie 10 projects = 10 Guids.

So naturally, when the table is filtered, it displays the data from that project, however "Project Name" is obviously not one of the values available in that DataGridView, as again, it reads from tblData.

Is it possible to replace the Guid that is displayed within that DataGridView with the corresponding "Project Name"?

+3  A: 

It's possible to add data columns from other datatables to a dataview / datatable which is bound to a datagrid. But building a JOIN on the SQL / LINQ Level would be the better solution.

Henrik P. Hessel
+2  A: 

I am not sure how you are getting your data back but you sould be joining to that other table and making the project name part of the result set.

If you can provide more information on how you are retrieving the data it would make this easier to answer.

Kelsey
Data is being gathered through the standard BindingSource process that VS2005 uses for forms, built through the designer.
scrot
+1  A: 

That is a pretty standard requirement. The issue isn't so much how to display data from two tables in the DataGridView, but how to setup the ComboBox in the DataGridView when you have a foreign key.

You might look at this article for some more info on the topic: http://www.informit.com/articles/article.aspx?p=446453&seqNum=9

Chris Brandsma
A: 

I was able to modify the schema of the table adapter. Opened it up, visually added the table and the column I needed. Thanks folks.

scrot