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

Listbox Re-Order failing

5 Answers 51 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 03 Feb 2014, 02:47 PM
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?

5 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 06 Feb 2014, 11:13 AM
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.
0
Timothy
Top achievements
Rank 1
answered on 06 Feb 2014, 08:13 PM
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?
0
Plamen
Telerik team
answered on 11 Feb 2014, 01:16 PM
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.
0
Timothy
Top achievements
Rank 1
answered on 19 Feb 2014, 07:46 PM
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.
0
Plamen
Telerik team
answered on 24 Feb 2014, 12:21 PM
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.
Tags
ListBox
Asked by
Timothy
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Timothy
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or