質問

I'm trying to add 2 datasets to one datagridview.

for example, dataset1 is filled with datatable1 and dataset2 is filled with datatable2.

I use this to add dataset1 to my datagridview :

datagridview.Datasource = dataset1.Tables[0];    

Now I want to add datset2 to the datagridview without clearing data that it contains.

the name of columns in both datatables are same.

Can anyone help me????

Regards

役に立ちましたか?

解決

You can try merging your data tables like following:

DataTable datasource = dataset1.Tables[0];
datasource.Merge(dataset2.Tables[0]);

datagridview.Datasource = datasource;

this can also work:

((DataTable)datagridview.Datasource).Merge(dataset2.Tables[0])

and then refresh the grid view

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top