aspnet-devexpress-dot-web-dot-aspxgridview-d79354f1.md
Returns a collection of sorted columns.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public ReadOnlyCollection<GridViewDataColumn> GetSortedColumns()
Public Function GetSortedColumns As ReadOnlyCollection(Of GridViewDataColumn)
| Type | Description |
|---|---|
| ReadOnlyCollection<GridViewDataColumn> |
The collection of sorted columns.
|
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.
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
KeyFieldName="ProductID" OnCustomCallback="grid_CustomCallback">
<Columns>
<%--...--%>
</Columns>
</dx:ASPxGridView>
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
var collection = ASPxGridView1.GetSortedColumns();
foreach(var item in collection) {
item.SortDescending();
}
}
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