In this post we will discuss how to remove columns from a datatable in Asp.Net.
Also you can check out:
- Tutorial on WPF Controls and Layout
- Cross-page posting in Asp.Net
- Convert ArrayList to String using C#.Net
DataTable represents one table of in-memory data. It contains rows and columns. You can also check out this article, if you want to create a datatable at runtime.
Suppose you want to delete a column from a datatable, they you can delete by using the column name or the column index.
dt.Columns.Remove("Name"); // Here it will remove the Name column from the datatable.
or
dt.Columns.Remove(2); // Here it will delete the 3rd column from the datatable, because index starts from 0.
Here dt is the object name of my datatable.
Also you can check out:
- Tutorial on WPF Controls and Layout
- Cross-page posting in Asp.Net
- Convert ArrayList to String using C#.Net
DataTable represents one table of in-memory data. It contains rows and columns. You can also check out this article, if you want to create a datatable at runtime.
Suppose you want to delete a column from a datatable, they you can delete by using the column name or the column index.
dt.Columns.Remove("Name"); // Here it will remove the Name column from the datatable.
or
dt.Columns.Remove(2); // Here it will delete the 3rd column from the datatable, because index starts from 0.
Here dt is the object name of my datatable.