Items.Count always return 0

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

    Posted 08 Jun 2011 Link to this post


    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???

  2. Vlad
    Vlad avatar
    11100 posts

    Posted 09 Jun 2011 Link to this post


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

    Kind regards,
    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. DevCraft R3 2016 release webinar banner
  4. cha
    cha avatar
    20 posts
    Member since:
    Mar 2011

    Posted 23 Jun 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.

  5. Stefan X1
    Stefan X1 avatar
    482 posts

    Posted 24 Jun Link to this post


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

    Hope this helps.

    Stefan X1
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top