You can create copy of existing data table and than remove unwanted data columns from data table
Following is code:
DataTable dtSourceCopy = dtSource.Copy();
DataColumnCollection columnsArray = dtSourceCopy .Columns;
foreach (var item in columnsArray)
{
if (!selectedColumns.Contains(item.ToString()))
{
dtSource.Columns.Remove(item.ToString());
}
}
No comments:
Post a Comment