Index out of range on tab switch

1 posts, 0 answers
  1. Kieran
    Kieran avatar
    1 posts
    Member since:
    May 2016

    Posted 11 May 2018 Link to this post

    We have a RadListBox where we are adding and removing items via client side code (sample add shown):

    ListBox_AddItem = function (listbox, text, value) {
        var item = new Telerik.Web.UI.RadListBoxItem();
        var attributes = item.get_attributes();
        attributes.setAttribute("Name", text);
        attributes.setAttribute("ID", value);

        return false;

    <telerik:RadListBox runat="server" ID="RadListBox" ClientIDMode="AutoID"
                                                            <%# Eval("Name") %>
                                                        <td id="DeleteColumn" style="float: right">
                                                            <a href="" onclick="return deleteRequestedBy('<%# Eval("id") %>')">
                                                                <img src="Images/deletered.png" width="20" height="20" alt="submit" />
                                                            #= Attributes.Name#
                                                        </td >
                                                        <td id="DeleteColumn" style="float:right">
                                                            <a href="" onclick="return deleteRequestedBy('#= Attributes.ID#')">
                                                                <img src="Images/deletered.png" width="20" height="20" alt="submit" />


    The ListBox is in a Tab on a RadTabStrip. When we add or remove items from the ListBox and then click on one of the other tabs we get an error:

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

    at System.Collections.ArrayList.get_Item(Int32 index)
    at System.Web.UI.StateManagedCollection.System.Collections.IList.get_Item(Int32 index)
    at Telerik.Web.UI.ControlItemCollection.get_Item(Int32 index)
    at Telerik.Web.UI.ClientStateLogPlayer`1.Remove(ControlItemCollection items, Int32 index)
    at Telerik.Web.UI.ClientStateLogPlayer`1.Play(ClientStateLogEntry entry)
    at Telerik.Web.UI.ClientStateLogPlayer`1.Play(IEnumerable`1 clientStateLogEntry)
    at Telerik.Web.UI.RadListBox.LoadLogEntries(RadListBoxClientState clientState)
    at Telerik.Web.UI.RadListBox.LoadClientState(RadListBoxClientState clientState)
    at Telerik.Web.UI.RadListBox.LoadPostData(String postDataKey, NameValueCollection postCollection)
    at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
    at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    I've tried the solutions suggested (along with some variations):

    However, none of the suggestions worked and don't seem to quite apply in this scenario i.e. we are not transferring.



Back to Top