We can remove Column in DatatTable by using DataColumnCollection.Remove method as follows.
private void RemoveColumnByName(string columnName)
{
// Get the DataColumnCollection from a DataTable
DataColumnCollection columns =dt.Columns;
if (columns.Contains(columnName))
if (columns.CanRemove(columns[columnName]))
columns.Remove(columnName);
}
private void RemoveColumnByName(string columnName)
{
// Get the DataColumnCollection from a DataTable
DataColumnCollection columns =dt.Columns;
if (columns.Contains(columnName))
if (columns.CanRemove(columns[columnName]))
columns.Remove(columnName);
}
No comments:
Post a Comment