DataGridColumnCollection::Remove Method
Removes the specified DataGridColumn-derived column object from the DataGridColumnCollection collection.
Assembly: System.Web (in System.Web.dll)
Parameters
- column
- Type: System.Web.UI.WebControls::DataGridColumn
The DataGridColumn-derived column to remove from the DataGridColumnCollection.
Use this method to remove the specified DataGridColumn-derived column object from a DataGridColumnCollection collection.
The DataGrid control does not store the contents of its Columns collection in the view state. To add or remove a column dynamically, you must programmatically add or remove the column every time the page is refreshed. Provide a Page_Init function that adds or removes the column before the DataGrid control can reload its state and rebuild itself. Otherwise, the changes to the Columns collection are not reflected in the DataGrid control when it is displayed.
The following code example demonstrates how to use the Remove method to remove a column from the DataGridColumnCollection collection. Note that the Columns property of the DataGrid control is the DataGridColumnCollection collection.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note