Skip to main content
Tab

ASPxGridView.SortBy(GridViewColumn, ColumnSortOrder) Method

Sorts data by the values of the specified data column in the specified sort order.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public ColumnSortOrder SortBy(
    GridViewColumn column,
    ColumnSortOrder value
)

Parameters

Name Type Description
column GridViewColumn

A grid column.

value ColumnSortOrder

The column’s sort order.

Returns

Type Description
ColumnSortOrder

The column’s sort order.

Remarks

The SortBy method sorts data in the grid by the column’s values in the specified sort order.

To define the column’s sort priority among columns, use the SortIndex property.

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

<dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="ProductID">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0" /> 
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1" /> 
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2" />
        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="3" />
    </Columns>
</dx:ASPxGridView>
protected void Page_Load(object sender, EventArgs e) {
    ASPxGridView1.SortBy(ASPxGridView1.Columns["ProductName"], DevExpress.Data.ColumnSortOrder.Ascending);
    ASPxGridView1.SortBy(ASPxGridView1.Columns["UnitPrice"], DevExpress.Data.ColumnSortOrder.Ascending);
    ASPxGridView1.SortBy(ASPxGridView1.Columns["Discontinued"], DevExpress.Data.ColumnSortOrder.Ascending);
}
See Also