Back to Devexpress

ASPxGridView.AllColumns Property

aspnet-devexpress-dot-web-dot-aspxgridview-c99b1296.md

latest3.1 KB
Original Source

ASPxGridView.AllColumns Property

Gets the collection of all columns within the ASPxGridView control.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public ReadOnlyGridColumnCollection<GridViewColumn> AllColumns { get; }
vb
Public ReadOnly Property AllColumns As ReadOnlyGridColumnCollection(Of GridViewColumn)

Property Value

TypeDescription
ReadOnlyGridColumnCollection<GridViewColumn>

A collection of all the columns in an ASPxGridView.

|

Remarks

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.

Example

This sample demonstrates how the AllColumns method can be used to centrally define a display format for all date columns within a ASPxGridView control.

csharp
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";
       }
    }
aspx
<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

Columns

Bands

Grid View

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace