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

RadListBox in RadListView EnableLoadonDemand

1 Answer 86 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Patrick Rills
Top achievements
Rank 1
Patrick Rills asked on 07 Jun 2012, 01:46 PM
I have an application scenario where the user is allowed to pick more than one item from more than one category of items.  I've solved this by creating a RadListView that will be bound to the categories and then using an ItemTemplate in the ListView to create a RadListBox for each category that will allow the user to select options in each category.  Everything was working great until one of the categories ended up having over 10,000 possible options to choose from.  I decided to try to solve this problem by setting EnableLoadOnDemand to true on the RadListBox in the ItemTemplate so it wouldn't try to render every item for every category to the page when it first loaded.  However, this doesn't work at all.  If I try to bind the ListView on Page Load, I get a weird error.  If I bind the ListView later (on a button click) I get blank RadListBoxes.  I've linked to a sample web project to show you what I'm trying to do.  Is this even possible?

http://www.iconstudios.org/RadListBoxinTemplate.zip

If I can't use EnableLoadOnDemand to accomplish this, what other strategies do you recommend for selecting from a huge list?

Thanks,

Patrick

1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 12 Jun 2012, 12:09 PM
Hello Patrick,

I reviewed your project and found out what is causing the problem. Here is what happens under the hood. When LoadOnDemand is set and RadListBox is tried to be bound without datasource an exception is thrown. In your case the when the ListView is bound every item is trying to bind its templates and the RadListBox control throws an exception, that is why you can not bind the RadListView on PageLoad.
To avoid that behavior you need to set EnableLoadOnDemand to true in the itemDataBound event handler.
I changed your project and sending it as an attachment. Keep in mind that the LoadOnDemand of the RadListBox control works only when the ListBox is bind on the first page load.
I am going to improve the RadListBox to render empty RadListBox when the control is bind to an empty datasource.

Regards,
Peter Filipov
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Patrick Rills
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question
or