I have two data tables. At first
DataTable NameAddressPhones = new DataTable();
with three columns Name, Address and PhoneNo . But I need only two columns Name and address , so I want to copy these columns (with data) into a new DataTable.
DataTable NameAddress = new DataTable();
For this I do
foreach (DataRow sourcerow in NameAddressPhones.Rows)
{
DataRow destRow = NameAddress.NewRow();
foreach (string colname in columns)
{
destRow[colname] = sourcerow[colname];
}
NameAddress.Rows.Add(destRow);
}
NameAddressPhones () DataTable , . , Nm , . , DataTable , Nm Add DataTable, DataTable. , , Nm DataTable DataTable DataTable DataTable.
, DataTable , , Nm - DataTable - DataTable, Nm .