Ticket Q481126
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Add a capability to display a real count of records in the ASPxGridView even when a grouping is applied

How to get the number of data rows in a filtered or grouped ASPxGridView

created 12 years ago

Is there a way to find out the number of rows in the filtered datasource in the ASPxGridView?

I can look at the datasource and do a .Count but that will give me the total count and not the user filtered count. If I use the VisibleRowCount it doesn't work if it's a grouped grid and user collapsed some of the groups.

I just want to know how many rows the grid have (after local filter applied).

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Ron,
This can be done by using the TotalSummary property. If you need to get the number of rows in code behind, handle the ASPxGridView.OnBeforeGetCallbackResult event and use the ASPxGridView.GetTotalSummaryValue method as shown below:

ASPx
<dx:ASPxGridView ID="grid" runat="server" DataSourceID="Products" KeyFieldName="ProductID" OnBeforeGetCallbackResult="grid_BeforeGetCallbackResult"> <Settings ShowFilterRow="true" ShowGroupPanel="true" ShowFooter="true" /> <TotalSummary> <dx:ASPxSummaryItem FieldName="ProductID" SummaryType="Count"/> </TotalSummary> </dx:ASPxGridView>
C#
protected void grid_BeforeGetCallbackResult(object sender, EventArgs e) { int rowCount = (int)grid.GetTotalSummaryValue(grid.TotalSummary["ProductID"]); }

I've attached a simple project for demonstration purposes.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.