Gets a collection of objects that represent the columns of the DataGrid control.
Assembly: System.Web (in System.Web.dll)
[<PersistenceModeAttribute(PersistenceMode.InnerProperty)>] abstract Columns : DataGridColumnCollection with get [<PersistenceModeAttribute(PersistenceMode.InnerProperty)>] override Columns : DataGridColumnCollection with get
Property ValueType: System.Web.UI.WebControls.DataGridColumnCollection
A DataGridColumnCollection object that contains a collection of objects that represent the columns of the DataGrid control.
Explicitly declared columns may be used in conjunction with automatically generated columns. When using both, explicitly declared columns will be rendered first, followed by the automatically generated columns. Automatically generated columns are not added to the collection.
The order that the columns are displayed in the DataGrid control is controlled by the order that the columns appear in the collection.
The following table shows the different column classes that derive from the DataGridColumn class and can be used in the collection.
Displays a column bound to a field in a data source. It displays each item in the field as text. This is the default column type of the DataGrid control.
Displays a command button for each item in the column. This allows you to create a column of custom button controls, such as the Add or Remove button.
Displays a column that contains editing commands for each item in the column.
Displays the contents of each item in the column as a hyperlink. The contents of the column can be bound to a field in a data source or static text.
Displays each item in the column following a specified template. This allows you to provide custom controls in the column.
Although you can programmatically add columns to the collection, it is easier to list the columns statically and then use the Visible property to show or hide the column.