Listbox Re-Order failing

6 posts, 0 answers
  1. Timothy
    Timothy avatar
    5 posts
    Member since:
    Oct 2013

    Posted 03 Feb 2014 Link to this post

    I have a radlistbox that is displaying the contents of a Queue table in a database using a Linq data source. The point of the page is to allow administrators to change the order of items in the Queue. There is a thread that is running elsewhere that is processing items in the queue and removing them. The page with the list box on it refreshes every 20 seconds automatically. If the thread processing the Queue removes an item from the table in-between page refreshes and I attempt to then reorder an item in the list before the grid re-binds I get the following error:

    "Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index"

    I am utilizing the AutoPostBackOnReorder property so that the listbox/data source manage all of the ordering. Is there a way to prevent the error I've described in this case?
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 06 Feb 2014 Link to this post

    Hello Timothy,

    Since you mentioned that the thread, which is running elsewhere performs operation of the DataSource of the RadListBox (deleting items), do you rebind the RadListBox? The issue is probably related with the fact that the datasource of the RadListBox is changed, while you attempt to perform the reordering on the items, which does not already exist. Please make sure that the ListBox is supplied with the correct DataSource, with using the RadListBox1.DataBind(). Thus, you will manually request the DataSource and you will ensure that this is the correct underlying data.

    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Timothy
    Timothy avatar
    5 posts
    Member since:
    Oct 2013

    Posted 06 Feb 2014 in reply to Nencho Link to this post

    Thanks for the response - the problem is that the thread that processes that table could remove a piece of data at any time while I only ReBind the list automatically every 20 secs. Would there be a way to rebind the list automatically at the beginning of any re-order event?
  5. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 11 Feb 2014 Link to this post

    Hi Timothy,

    Unfortunately there is no way to rebind the list automatically at the beginning of any re-order event this would break the functionality of the control.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  6. Timothy
    Timothy avatar
    5 posts
    Member since:
    Oct 2013

    Posted 19 Feb 2014 in reply to Plamen Link to this post

    Yes I suppose rebinding the control before a reorder would defeat the purpose. However, I'm still looking to determine the best way (and it may require me not using a Linq data source and depend on the auto reorder functionality) to use the built-in functionality while having it be smart about handling that error and case I outlined.
  7. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 24 Feb 2014 Link to this post

    Hi Timothy,

    One possible way that could be helpful in this scenario is to use onDropping event of RadListBox and cancel the event if any change of the datasource have been applied. 

    Hope this will be helpful.

    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017