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

Error combining CheckBoxes, AutoPostBack and EnableVirtualScrolling

1 Answer 102 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rubens
Top achievements
Rank 1
Rubens asked on 04 Jan 2012, 04:53 PM
I have this ASPX code:

<telerik:RadComboBox runat="server" ID="instituicao" Width="450" CheckBoxes="true"
        AutoPostBack="true" ItemsPerRequest="10"
        EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
        OnItemChecked="instituicao_ItemChecked" OnItemsRequested="instituicao_ItemsRequested" />

And this code behind:
protected void instituicao_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    DataTable dt = GetData();
    int total = dt.Rows.Count;
    int itemOffset = e.NumberOfItems;
    int endOffset = Math.Min(itemOffset + instituicao.ItemsPerRequest, total);
    e.EndOfItems = endOffset == total;
    instituicao.Items.AddRange(
        dt.Rows.OfType<DataRow>().Skip(itemOffset).Take(endOffset - itemOffset)
               .Select(i => new RadComboBoxItem(i["Id"] as string, i["Id"] as string)));
}
 
protected void instituicao_ItemChecked(object sender, RadComboBoxItemEventArgs e)
{
    // do stuff
}
 
private DataTable GetData()
{
    DataTable dt = new DataTable();
    dt.Columns.Add("Id", typeof(string));
    for (int i = 1; i <= 100; i++ )
    {
        DataRow row = dt.NewRow();
        row["Id"] = i;
        dt.Rows.Add(row);
    }
     return dt;
}

When I check an item I got this error and my code is never executed:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.ArrayList.get_Item(Int32 index) +7487944
   System.Web.UI.StateManagedCollection.System.Collections.IList.get_Item(Int32 index) +12
   Telerik.Web.UI.ControlItemCollection.get_Item(Int32 index) +48
   Telerik.Web.UI.RadComboBoxItemCollection.get_Item(Int32 index) +37
   Telerik.Web.UI.RadComboBox.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +238
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Any clues?

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 05 Jan 2012, 03:50 PM
Hi,

I am afraid that simultaneous usage of CheckBoxes and Load On Demand is not supported.
Please take a look at the "CheckBox Support" help article where this topic is described in details.
Additionally at this online demo you can test the RadComboBox behaviour under different configurations.

Regards,
Kalina
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
ComboBox
Asked by
Rubens
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or