Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.GroupBy(GridViewColumn, Int32) Method

Groups data by the values of the specified column. If several columns are involved in grouping, the specified column will reside at the specified grouping level.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

public int GroupBy(
    GridViewColumn column,
    int value
)

Parameters

Name Type Description
column GridViewColumn

A GridViewColumn descendant that represents the data column within the ASPxGridView.

value Int32

An integer value that specifies the grouping level. -1 to cancel grouping by the column’s values.

Returns

Type Description
Int32

An integer value that specifies the grouping level.

Remarks

The ASPxGridView supports grouping data by an unlimited number of data columns. To group data by the values of the specified column, use the GroupBy method. You can also use the column’s GridViewDataColumn.GroupBy method.

Calling the GroupBy method has no effect if data is already grouped by the values of the specified column. If several columns are involved in grouping, the column will reside at the specified grouping level.

Data rows are always sorted against the grouping columns. If data is grouped against a column which isn’t sorted, the ASPxGridView automatically applies sorting in ascending order to the column.

To ungroup data by the values of a single column, use the ASPxGridView.UnGroup method or the column’s GridViewDataColumn.UnGroup method.

Data grouping is allowed if the ASPxGridViewBehaviorSettings.AllowGroup and ASPxGridBehaviorSettings.AllowSort properties are set to true.

Example

The following code shows how to group by two columns (“Country” and “City”).

The image below shows the result.

exGrouping

((GridViewDataColumn)ASPxGridView1.Columns["City"]).GroupBy();
ASPxGridView1.GroupBy(ASPxGridView1.Columns["Country"], 0);
See Also