Click here to Skip to main content
15,306,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to copy dynamically selected columns of one data-table to another data table.
Posted
Comments
Monjurul Habib 12-Dec-11 10:59am
   
clarify ..explain clearly what do you want ?

1 solution

DataTable class in .NET framework will help you. Herez an example to copy the columns of PresentAddress table to PermanantAddress table.

C#
DataTable PresentAddress = new DataTable(); 
DataTable PermanantAdress = new DataTable(); 

foreach (DataRow sourcerow in PresentAddress .Rows)
{
    DataRow destRow = PermanantAdress.NewRow();
    destRow["Name"] = sourcerow["Nam"];
    destRow["Address"] = sourcerow["Addr"];
    PermanantAdress.Rows.Add(destRow);
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900