Back to Devexpress

ASPxGridView.GetSortedColumns() Method

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

latest2.4 KB
Original Source

ASPxGridView.GetSortedColumns() Method

Returns a collection of sorted columns.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public ReadOnlyCollection<GridViewDataColumn> GetSortedColumns()
vb
Public Function GetSortedColumns As ReadOnlyCollection(Of GridViewDataColumn)

Returns

TypeDescription
ReadOnlyCollection<GridViewDataColumn>

The collection of sorted columns.

|

Remarks

ASPxGridView supports data sorting by multiple columns. Call the GetSortedColumns method to access the collection of sorted columns.

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

The code sample below uses the GetSortedColumns method to traverse through the sorted columns and sort them in descending order.

aspx
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
    KeyFieldName="ProductID" OnCustomCallback="grid_CustomCallback">
    <Columns>
        <%--...--%>
    </Columns>
</dx:ASPxGridView>
csharp
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
    var collection = ASPxGridView1.GetSortedColumns();
    foreach(var item in collection) {
        item.SortDescending();
    }
}
vb
Protected Sub grid_CustomCallback(ByVal sender As Object, ByVal e As ASPxGridViewCustomCallbackEventArgs)
    Dim collection = ASPxGridView1.GetSortedColumns()

    For Each item In collection
        item.SortDescending()
    Next
End Sub

See Also

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace