Any trick to get this to work in DataColumn of DataTable?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Say I have a table of companies, and a table of industries (like
automobiles, steel, computers, etc..) A company may be involved in
industries, so there's a third table- a mapping table- which just keys a
company to a specific industry. This table can have multiple rows for a
single company, since some companies can be involved in multiple industries.

Now when I display Companies in a DataGrid, I want a column that prints out
all the industries it is involved in- in a comma-separated string. So one
column's data might look like "Automobiles, Machine Tools, Aeronautics" if
there are 3 rows for that company mapping it to each of those industries.

Now the trick is, how would I accomplish this just using DataTable
expression? No real SQL, just whatever the DataColumn expression syntax has
to offer... is it possible?
 
The DataColumn expression syntax is just for processing the data in that
column in that table, it isn't suited for retrieving data from other tables.
You'll have to do that in code yourself, probably after you fill your
dataset you could add a new calculated column, loop through the rows,
retrieve the industries data and synthetically create the value for the
column.
 
Back
Top