We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

counting number of rows in DataGridControl

Thread ID:





114534 Nov 22,2013 08:25 PM UTC Dec 4,2013 12:47 PM UTC WPF 2
Tags: GridControl
Joseph Lopez
Asked On November 22, 2013 08:25 PM UTC

I need a way to hide the data grid control when there are no records. In the native WPF implementation it would be done like this:
DependencyObject obj = (DependencyObject)e.OriginalSource;
            if (obj is DataGrid)
                if ((obj as DataGrid).Items.Count == 0)
                    (obj as DataGrid).Visibility = Visibility.Collapsed;

however items is not a property on the WPF Data Grid Control. How can this be done? thanks

Joseph Lopez
Replied On November 22, 2013 08:30 PM UTC

found it

if ((obj as Syncfusion.Windows.Controls.Grid.GridDataControl).Model.RowCount <= 1) //header is counted
                    (obj as Syncfusion.Windows.Controls.Grid.GridDataControl).Visibility = Visibility.Collapsed;

Saravanan M [Syncfusion]
Replied On December 4, 2013 12:47 PM UTC

Hi Joseph,

Thanks for you update,

You can also get the Rowcount by applying below code snippet.


int count = this.syncgrid.Model.RowCount;


Please let us know if you have any queries,




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon