Binding multiple datasets to one datagrid

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
 
G

Guest

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!
***************************
 
H

Homer J. Simpson

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
 
C

Cor Ligthert [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top