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

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

5 Answers 164 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jonathan Torres
Top achievements
Rank 1
Jonathan Torres asked on 08 Jul 2010, 12:12 AM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 08 Jul 2010, 09:16 AM
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
0
Jonathan Torres
Top achievements
Rank 1
answered on 08 Jul 2010, 04:32 PM
Thank you, that worked.
0
Hanso Gnana
Top achievements
Rank 1
answered on 17 Aug 2010, 01:34 AM
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!
0
Yana
Telerik team
answered on 17 Aug 2010, 08:30 AM
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
0
Hanso Gnana
Top achievements
Rank 1
answered on 18 Aug 2010, 01:29 AM
Many thanks.
Tags
ListBox
Asked by
Jonathan Torres
Top achievements
Rank 1
Answers by
Yana
Telerik team
Jonathan Torres
Top achievements
Rank 1
Hanso Gnana
Top achievements
Rank 1
Share this question
or