Current filter:
                                You should refresh the page.
                                Support Center
                                  • Hi

                                    I am trying to automatically display the detail row if only 1 record is returned from either the initial query or after a filter. I am using the following code to do so:

                                    protected void Grid_DataBound(object sender, EventArgs e) { if (Grid.VisibleRowCount == 1) Grid.DetailRows.ExpandRow(0); }
                                    This is working if the datasource only contains 1 record but it does not work for filtering. If i put a breakpoint in this method then after the filter, the VisibleRowCount is the original DataSource count. If I then clear the filter, VisibleRowCount is now equal to 1 and expands the row but more than one record is displayed so it is doing it too late. I have attached a sample project.

                                    Is this a bug or should my code be in a different event?


                                1 Solution

                                Creation Date Rating Importance Sort by


                                Please handle the BeforeGetCallbackResult event instead.

                                • Renae 01.21.2013

                                  This works for the filtering but doesn't for when the datasource is first set so i've left it in both events. This does mean it fires after clearing the filter (as the databound event still thinks VisibleRowCount is 1) but that row will already be expanded so isn't a big deal.

                                • Hi,

                                  >>This works for the filtering but doesn't for when the datasource is first set
                                  This behavior is caused by the fact that the ASPxGridView.BeforeGetCallbackResult event fires only on the grid's callbacks and doesn't fire either when the page is loaded for the first time or on postbacks. So, to avoid the double call of the ExpandRow method, use the ASPxWebControl.IsCallback property to check if the grid's callback was sent:

                                  protected void Grid_DataBound(object sender, EventArgs e) { if (!Grid.IsCallback && Grid.VisibleRowCount == 1) Grid.DetailRows.ExpandRow(0); }

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners