Back to Devexpress

GridViewDataColumn.SortAscending() Method

aspnet-devexpress-dot-web-dot-gridviewdatacolumn-143a48ca.md

latest2.5 KB
Original Source

GridViewDataColumn.SortAscending() Method

Sorts the column in ascending order.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public void SortAscending()
vb
Public Sub SortAscending

Remarks

When you call the SortAscending() or SortDescending() method, the grid sorts the column in ascending or descending order and sets its SortOrder property to the corresponding value.

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

aspx
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="ProductID">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0" />
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1" />
        <dx:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="2" />
        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="3" />
        <dx:GridViewDataTextColumn FieldName="UnitsOnOrder" VisibleIndex="4" />
    </Columns>
</dx:ASPxGridView>
csharp
protected void Page_Load(object sender, EventArgs e) {
    var column0 = (GridViewDataColumn)grid.Columns["Discontinued"];
    var column1 = (GridViewDataColumn)grid.Columns["UnitPrice"];
    column0.SortDescending();
    column1.SortAscending();
}
vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim column0 = CType(grid.Columns("Discontinued"), GridViewDataColumn)
    Dim column1 = CType(grid.Columns("UnitPrice"), GridViewDataColumn)
    column0.SortDescending()
    column1.SortAscending()
End Sub

See Also

GridViewDataColumn Class

GridViewDataColumn Members

DevExpress.Web Namespace