0

I want to merge two or more DataTables Colum by Column. I am developing C# Windows Application. My use case is below:

  1. I have empty data grid in my application.
  2. user will drag and drop one column from available column list box into data grid. The data grid will start displaying data for that column.
  3. Now, I will drag another column into data grid and now grid should get populated data of two columns.
  4. This will repeat till user feels that he has dropped all necessary columns.

What is best way to do this? Is there any performance hits with large number of rows typically 1 million?

Please help.

Thanks, Omky

1 Answer 1

1

use DataTable.Merge if you really want to marge datasets

keep empty datatable with id, and each time user add new column, marge first datatable with new datatable containing id and new column

But in your case, I think it will be better to bind full datatable to grid, and change visible of or add remove datagrid column depending user action

Sign up to request clarification or add additional context in comments.

2 Comments

Yes that is true!!! but my requirement is I want to fetch the data for that particular column when user drag and drop the column. BTW is there any constraint that merging should be based upon primary keys of two tables?
yes, for margin constraint is needed, see msdn.microsoft.com/en-us/library/fk68ew7b.aspx example, you can add column to that datatable,and fill them from first one manually

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.