Items.Count always return 0

7 posts, 0 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 08 Jun 2011 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Jun 2011 Link to this post

    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
  3. cha
    cha avatar
    23 posts
    Member since:
    Mar 2011

    Posted 23 Jun 2016 Link to this post

    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.

  4. Stefan X1
    Admin
    Stefan X1 avatar
    740 posts

    Posted 24 Jun 2016 Link to this post

    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.
  5. Александр
    Александр avatar
    3 posts
    Member since:
    Jul 2017

    Posted 27 Jul Link to this post

    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?

  6. Александр
    Александр avatar
    3 posts
    Member since:
    Jul 2017

    Posted 27 Jul Link to this post

    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.

  7. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    570 posts

    Posted 31 Jul Link to this post

    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 allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top