ASPxGridView.GroupCount Property
Gets how many columns are used to group data.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.1.dll
Declaration
Property Value
Type | Description |
---|---|
Int32 | An integer value that indicates the number of columns used to group data. |
Remarks
The grouped columns can be obtained using the ASPxGridView.GetGroupedColumns method.
Example
In this example, we have an ASPxGrid bound to SqlDataSource. The data source returns columns. We grouped the grid by one of them. Also, the grid contains an additional unbound column 'percent'. It contains the ratio of the 'UnitPrice' column's value to total 'UnitPrice' column's values for this group. If the grid doesn't have any groups, the 'percent' column will contain the ratio of the 'UnitPrice' column's value to total 'UnitPrice' column's values of the grid.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-implement-percentage-values-calculation-in-a-gridview-unbound-column-for-a-group-e3006
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="sds"
KeyFieldName="ProductID" OnCustomUnboundColumnData="grid_CustomUnboundColumnData">
<TotalSummary>
<dx:ASPxSummaryItem DisplayFormat="c2" FieldName="UnitPrice" SummaryType="Sum" />
</TotalSummary>
<GroupSummary>
<dx:ASPxSummaryItem DisplayFormat="c2" FieldName="UnitPrice"
ShowInGroupFooterColumn="UnitPrice" SummaryType="Sum" />
</GroupSummary>
<Columns>
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryID" GroupIndex="0" SortIndex="0" SortOrder="Ascending"
VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3">
<PropertiesTextEdit DisplayFormatString="c2">
</PropertiesTextEdit>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="percent" UnboundType="Decimal" VisibleIndex="3">
<PropertiesTextEdit DisplayFormatString="p2">
</PropertiesTextEdit>
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
</Columns>
<Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" ShowGroupPanel="True" />
</dx:ASPxGridView>
<asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT TOP 20 [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GroupCount property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.