0

I have two datatables(i don't have any database table, just simple datatable) as shown in screenshot (datatable1 and datatable2).

DataTable datatable1= new DataTable();
 new_Table.Columns.Add("Name");
 new_Table.Columns.Add("Number_A");
 new_Table.Columns.Add("Comment");
 new_Table.Columns.Add("ID");

DataTable datatable2= new DataTable();
 new_Table.Columns.Add("Name");
 new_Table.Columns.Add("Number_B");
 new_Table.Columns.Add("Age");
 new_Table.Columns.Add("City");

enter image description here

after binding them I want to compare two datatable and merge rows with similar "Name's column" value and add other rows also as you see in screenshot, and create new datatable named result datatable...

Can you please explain to me how to achieve this?

Thanks

programmer
  • 29
  • 5
  • https://learn.microsoft.com/en-us/dotnet/api/system.data.datatable.merge?view=netframework-4.8 – JB's Dec 02 '19 at 10:22
  • check this link for merge Datatable https://stackoverflow.com/questions/285474/merge-2-datatables-and-store-in-a-new-one – JB's Dec 02 '19 at 10:23
  • https://stackoverflow.com/a/12284003/5985558 – JB's Dec 02 '19 at 10:28
  • this method (data_table.merge) just return all dupplicate rows, i want to merge row with similar Name into one row and add other rows also to result datatable ... – programmer Dec 02 '19 at 10:33

0 Answers0