After deleting last item, ajax call fails

4 posts, 0 answers
  1. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 05 Aug 2014 Link to this post

    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.

  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 08 Aug 2014 Link to this post

    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.

     
  3. Johnathan
    Johnathan avatar
    39 posts
    Member since:
    Sep 2012

    Posted 22 Feb in reply to Peter Filipov Link to this post

    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

  4. Johnathan
    Johnathan avatar
    39 posts
    Member since:
    Sep 2012

    Posted 22 Feb in reply to Johnathan Link to this post

    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

Back to Top