listBox.get_items().add(item) and Count=0

6 posts, 1 answers
  1. Jonathan Torres
    Jonathan Torres avatar
    5 posts
    Member since:
    Jul 2009

    Posted 07 Jul 2010 Link to this post

    I am transferring the contents of one radlistbox to another using javascript:

    item.set_text(doc10.get_text());
    item.set_value(doc10.get_text());
    listBox.get_items().add(item);

    After I have added all the items, the following statement will return the # of items in the listbox: listBox.get_items()._array.length

    After this, I submit my page and I'm trying to access the contents of the listbox in the codebehind, but RadListbox.Items.Count returns 0.

    Can anyone explain why this is happening?  I am using Q2 2009 RadListbox.

    Thanks,
    Jon
  2. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 Jul 2010 Link to this post

    Hi Jon,

    You should use trackChanges() and commitChanges() methods of the listbox in order to preserve the changes to the server. You can check this help article about this.

    Best regards,
    Yana
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jonathan Torres
    Jonathan Torres avatar
    5 posts
    Member since:
    Jul 2009

    Posted 08 Jul 2010 Link to this post

    Thank you, that worked.
  5. Hanso Gnana
    Hanso Gnana avatar
    4 posts
    Member since:
    Aug 2010

    Posted 16 Aug 2010 Link to this post

    Hello,

    In this thread, Jon said "After I have added all the items, the following statement will return the # of items in the listbox: listBox.get_items()._array.length".

    It worked for me too. But could someone please comment on where in the documentation its mentioned that this is the way to access the count of a collection. I spent some time looking for it and did not find it anywhere - only when I came across this thread (kudos to this forum).

    Thanks!
  6. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 Aug 2010 Link to this post

    Hello Hanso,

    Actually _array is a private property, that's why it's not mentioned in the documentation, the correct way is to use get_count() method of the items collection as shown here.

    Best regards,
    Yana
    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
  7. Hanso Gnana
    Hanso Gnana avatar
    4 posts
    Member since:
    Aug 2010

    Posted 17 Aug 2010 Link to this post

    Many thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017