My DataTable
has many columns more than 35 columns. Among them I want to copy the first column "SYMBOL_QA" data to another new DataTable
.
I searched in internet but did not found any suitable approaches. One approach I found was to copy the whole DataTable
as it is, then delete the unwanted columns. But I have 35 columns and deleting all of them one by one will not be good approach.
protected void SendDataTable(DataTable dSource)
{
DataTable dTarget = new DataTable();
dTarget.Columns.Add(new DataColumn("SYMBOL_QA_"));
int rowIdx = 0;
dTarget.AsEnumerable().All(row => { row["SYMBOL_QA_"] = dSource.Rows[rowIdx++]["SYMBOL_QA"]; return true; });
}
This code block is not working. How can I do this ?