Skip to main content
Tab

GridViewDataColumn.SortOrder Property

Specifies the column’s sort order.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(ColumnSortOrder.None)]
public virtual ColumnSortOrder SortOrder { get; set; }

Property Value

Type Default Description
ColumnSortOrder None

The column’s sort order.

Available values:

Name Description
None

No sorting is applied to a column.

Ascending

Sorts the column in ascending order.

Descending

Sorts the columns in descending order.

Remarks

The SortOrder property allows you to specify the column’s sort order:

  • When you change the sort order, the control keeps the previous sort settings and applies an additional condition.

  • When you specify the SortOrder property for a non-sorted column, the control adds this column to the collection of sorted columns and applies the specified sort order to the column.

You can also use the following methods to change or disable the column’s sort order:

SortAscending()
Sorts the column in ascending order.
SortDescending()
Sorts the column in descending order.
UnSort()
Clears the sorting applied to the column.

For more information on sorting in the grid, refer to the following topic: ASPxGridView - Sort Data.

<dx:ASPxGridView ID="grid" runat="server" KeyFieldName="CustomerID" AutoGenerateColumns="false">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ContactName" SortOrder="Ascending" />
        <dx:GridViewDataTextColumn FieldName="CompanyName" />
        <dx:GridViewDataTextColumn FieldName="City" />
        <dx:GridViewDataCheckColumn FieldName="Discontinued" />
        <dx:GridViewDataTextColumn FieldName="Country" />
    </Columns>
</dx:ASPxGridView>
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    // Specify the column's sort order in code
    var column = (GridViewDataColumn)grid.Columns["Discontinued"];
    column.SortIndex = 0;
    column.SortOrder = DevExpress.Data.ColumnSortOrder.Descending;
}

Run Demo: ASPxGridView - Customization Dialog (Web Forms)

Run Demo: GridView - Customization Dialog (MVC)

The following code snippets (auto-collected from DevExpress Examples) contain references to the SortOrder property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also