RadListBox in RadListView EnableLoadonDemand

2 posts, 0 answers
  1. Patrick Rills
    Patrick Rills avatar
    5 posts
    Member since:
    Jan 2010

    Posted 07 Jun 2012 Link to this post

    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?


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


  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 12 Jun 2012 Link to this post

    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.

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top