aspnet-devexpress-dot-web-dot-aspxgridview-c99b1296.md
Gets the collection of all columns within the ASPxGridView control.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public ReadOnlyGridColumnCollection<GridViewColumn> AllColumns { get; }
Public ReadOnly Property AllColumns As ReadOnlyGridColumnCollection(Of GridViewColumn)
| Type | Description |
|---|---|
| ReadOnlyGridColumnCollection<GridViewColumn> |
A collection of all the columns in an ASPxGridView.
|
The AllColumns property provides access to a collection that contains all the columns of the ASPxGridView control (this includes columns of all the bands, if a banded layout is used). This collection is read-only, since individual columns can be manipulated (added or removed) at the level of a grid control (ASPxGridView.Columns) or a band column (GridViewColumn.Columns). The collection obtained via the AllColumns property allows you to easily iterate through all the grid columns and access any required column identified by its specific setting or type.
This sample demonstrates how the AllColumns method can be used to centrally define a display format for all date columns within a ASPxGridView control.
using DevExpress.Web.ASPxGridView;
...
public void ChangeDateColumnDisplayFormat() {
foreach(GridViewColumn column in Grid.AllColumns) {
GridViewDataDateColumn dateColumn = column as GridViewDataDateColumn;
if(dateColumn != null)
dateColumn.PropertiesDateEdit.DisplayFormatString = "d MMM yyyy";
}
}
<dx:ASPxGridView ID="Grid" runat="server" KeyFieldName="ID" AutoGenerateColumns="false">
...
<Columns>
<dx:GridViewBandColumn Caption="Band1">
<Columns>
<dx:GridViewDataDateColumn FieldName="Column1" />
<dx:GridViewDataColumn FieldName="Column2" />
</Columns>
</dx:GridViewBandColumn>
<dx:GridViewDataDateColumn FieldName="Column3" />
</Columns>
...
</dx:ASPxGridView>
See Also