This is a migrated thread and some comments may be shown as answers.

Items.Count always return 0

6 Answers 372 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 08 Jun 2011, 07:45 PM
Hi,

I'm using a RadGridView in my WPF projet and when I load my form, I assign the ItemsSource property of my RadGridView to an object representing an array of values. After that, I'm trying to display a label with the number of items in my grid but the RadGridView.Items.Count method always return 0.

Here is what I'm doing:

RadGridView.ItemsSource; = itemsGrid //Actually, itemsGrid contain 11 elements
GroupBox.Header = RadGridView.Items.Count.ToString(); //Always return 0.

But I can see the 11 elements in my grid!!!
Can you explain this???

Thank's

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 09 Jun 2011, 06:37 AM
Hi,

 It will be better to bind such properties since the grid will not create everything immediately when you assign ItemsSource. 

Kind regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
cha
Top achievements
Rank 1
answered on 23 Jun 2016, 04:04 PM

any idea if this was ever solved ?  I need to display the custom message that has the count value of number of rows in the grid.

I can't use the collection view that is bound to the grid as the user could have applied some column level filters on the grid.

My collection could have 1000 items but grid might be showing only 10 based on grid filters.

How do I get the correct number of rows being displayed on the grid.

0
Stefan
Telerik team
answered on 24 Jun 2016, 08:34 AM
Hello,

You can try using the Items collection of RadGridView, as the control performs all data operations, such as filtering over it.

Hope this helps.

Regards,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Александр
Top achievements
Rank 1
answered on 27 Jul 2017, 07:15 AM

Hello, guys. I am in similar situation. But I binded text box to Items.Count property. And I faced with this problem too. But I found an interesting issue - if I set DataLoadMoad="Asynchronous" for RadGridView - all works correct. So I have a big question - why it does working good in async mode (Items.Count return right value) but does not work in sync mode?

0
Александр
Top achievements
Rank 1
answered on 27 Jul 2017, 07:19 AM

Hello, guys.

I faced this problem too. But I have binded text box to Items.Count property of RadGridView. And I found an interesting solution for this problem. If i set DataLoadMode="Asynchronous" for RadGridView - than all works correct. But in synchrous mode Items.Count returns 0 on first initizlization.

 

Support, could you please answer why in async mode Items.Count works correct and works bad in sync mode? It bother me because of on Telerik tips and tricks async mode is not recommended to use.

0
Dilyan Traykov
Telerik team
answered on 31 Jul 2017, 02:09 PM
Hello Alexandr,

I responded in the other forum thread you opened. May I kindly ask you to continue any further communication on this issue there so that we can keep the conversation history in tact?

Thank you in advance for your cooperation on the matter.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Oliver
Top achievements
Rank 1
Answers by
Vlad
Telerik team
cha
Top achievements
Rank 1
Stefan
Telerik team
Александр
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or