Binding multiple datasets to one datagrid

  • Thread starter Thread starter Homer J. Simpson
  • Start date Start date
H

Homer J. Simpson

Hello,
I have an asp datagrid where i'd like to display four colums, each one
showing datas coming from a different dataset.
Each dataset has a common PK, so i'd like to make a join on this PK,
and fill a result dataset to bind it to my asp datagrid.
I can't find any samples showing this kind of technique.
Any ideas ?

Thanks in advance,
J.Philippe
 
That is not the way DataBinding works in .NET. To get around this you will
have to either a) mold the data to fit the model or b) create a custom
control.

Molding, version A
Rewrite data access to return the data you wish to bind in a single data
table (ie, mold the SQL to fit the results). Easiest, but least reusable.

Molding, version B
Create a routine that "merges" the data into a new data table and bind this
table.

Custom control
Accept the four DataTables as inputs into a custom control and "merge" the
data on the fly. This is the most time consuming. Done correctly, however,
you can end up with a reusable control.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Greg,
Thanks for your answer.

I was peeking thru the datarelation class. The idea was to fill an
unique Dataset with 4 tables (each one resulting from a different SQL
request), and then specify 4 data relations linking each PK of the
previous tables.

Do u think that the resulting dataset can passed as a data source for
my datagrid ?

Thanks again,
J.Philippe
 
In Addition to George.
Molding, version B
Create a routine that "merges" the data into a new data table and bind
this
table.
For this has the tablename, columname (1 per table), and key have exactly
the same names and fieldtypes as the resulttable.

I hope this helps,

Cor
 
Back
Top