RemoveColumn
public static void RemoveColumn(this System.Data.DataTable dt, string columnName) { if (dt != null && !string.IsNullOrEmpty(columnName) && dt.Columns.IndexOf(columnName) >= 0) { int idx = dt.Columns.IndexOf(columnName); dt.Columns.RemoveAt(idx); dt.AcceptChanges(); } }Example:
// Consider that dataSetName is the DataSet that contains a DataTable dataSetName.Tables[0].RemoveColumn("Column12");
Description
Code that allows deleting a column stating the name
Details
- Author: Raphael Augusto Ferroni Cardoso
- Submitted on: 6/4/2014 9:10:07 PM
- Language: C#
- Type: System.Data.DataTable
- Views: 1995
Double click on the code to select all.