Copy a datagrid datasource to another

G

Guest

Hi,

Is there a way to clone datasource of one datagrid to another?

I tried:
DataGrid2.datasource = DataGrid1.datasource
DataGrid2.Databind()

Does not seem to work
 
C

Craig Deelsnyder

Ed said:
Hi,

Is there a way to clone datasource of one datagrid to another?

I tried:
DataGrid2.datasource = DataGrid1.datasource
DataGrid2.Databind()

Does not seem to work

Try using a DataView of your datasource; actually 2 of them, 1 for each
grid. In essence by setting your datasource to a dataset (assuming
that's your original datasource, or even a DataTable), asp.net in the
background creates a dataview for its actual datasource

DataGrid1.Datasource = new DataView(mydataset.Tables(0))
....
DataGrid2.Datasource = new DataView(mydataset.Tables(0))

that should work..
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top