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

After deleting last item, ajax call fails

3 Answers 84 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
ido nahmias
Top achievements
Rank 1
ido nahmias asked on 05 Aug 2014, 10:27 AM
I am using a RadListBox for adding and deleting items. To delete the item from the list i use:  "listBox.deleteItem(selectedItem);" and items are deleted from the list successfully.  After adding items and deleting all of the items (leaving no items in the list) , an ajax call i make fails, and does not reach the required function on the server side. if no items are added to the list, or some items are added to the list, or some items are added and some are deleted but not all of the items the ajax call succeeds.  The exception i receive is:  "Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
"

Thanks for the help in advance.

3 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 08 Aug 2014, 07:30 AM
Hi Ido,

Please make sure that you call the track/commit changes methods and update the RadListBox control on every ajax call.
Could you send me a sample page which reproduces the behavior?

Regards,
Peter Filipov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Johnathan
Top achievements
Rank 1
answered on 22 Feb 2017, 07:29 PM

Hi Peter,

I'm running into a similar issue when deleting the first item in the list box control. The list is loaded during the first page_init subroutine and I'm trying to remove the first item in the list. I have the "AllowDelete" option set to true & the "ButtonSettings-ShowDelete" option set to true and I'm using the delete button provided by the control to remove the item. When I click the delete button, the item is removed, but as soon as I submit via a button control, I get the following error:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

Any guidance would be greatly appreciated. If there's a need to use the track/commit changes with the built-in delete button control for the list box, could you possibly send me the necessary JS code to do so?

Thanks,

Johnathan

0
Johnathan
Top achievements
Rank 1
answered on 22 Feb 2017, 08:49 PM

Never mind. I figured out my problem. ViewState wasn't enabled on the page, so the list box control updates weren't properly being saved.

Thanks,

Johnathan

Tags
ListBox
Asked by
ido nahmias
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Johnathan
Top achievements
Rank 1
Share this question
or