+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / RadControl ListBox throwing the following error message intermi

RadControl ListBox throwing the following error message intermi

3 posts, 0 answered
  1. satya chaluvadi
    satya chaluvadi avatar
    2 posts
    Registered:
    10 Jul 2009
    13 May 2010
    Link to this post
    We are using ListBox for selection of multiple values, some times we see the following error messge,  any one come across this kind of error message, if so could you please provide light on how to solve this kind of error message:
    Error Message: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    Stack Trace:    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)
    ---------------------------------------
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 May 2010
    Link to this post
    Hi satya chaluvadi,

    This type of error is  thrown by the .NET Framework, when you are accessing an item in an indexed object and the accessed index is out of bounds.  You have an ArrayList and you are trying to access an index that is not available. It looks like at the time your are trying to retrieve the data the RadListBox has no items. The problem is most probably related to the way you are binding this control and in which stage of its lifecycle you are doing this. You could attach your code to VS debugger and see when and why the error is raised. I suggest that you should take a look at the articles below as well



    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. satya chaluvadi
    satya chaluvadi avatar
    2 posts
    Registered:
    10 Jul 2009
    13 May 2010
    Link to this post

     

    <telerik:RadAjaxPanel style="position:relative; ">

     

     

    <telerik:RadListBox runat="server" style="position:relative;" ID="LAPGoals" AllowTransfer="true" TransferToID="APGoals" Width="370px" Height="140px" DataKeyField="address" DataTextField="name" SelectionMode="Multiple" >

     

     

    </telerik:RadListBox>

     

     

    <telerik:RadListBox runat="server" style="position:relative;" ID="APGoals" Width="280px" Height="140px" DataKeyField="address" DataTextField="name" >

     

     

    </telerik:RadListBox>

     

     

    </telerik:RadAjaxPanel>

     



    private string getRadListBoxSelection(RadListBox rlb)
            {
                StringBuilder strBRLBInfo = new StringBuilder();
                int indx = 0;
                foreach (RadListBoxItem item in rlb.Items)
                {
                 
                        if (indx == 0)
                            strBRLBInfo.Append(item.Value);
                        else
                            strBRLBInfo.Append("@" + item.Value);

                        indx++;
                  
                }
                return strBRLBInfo.ToString();
            }

            private void setRadListBoxSelection(Telerik.Web.UI.RadListBox ctl, string val)
            {
                RadListBoxItem ritem;
                string[] selArr = val.Split('@');
                List<string> keysin = new List<string>();
               
             
                if (ctl.ID.Equals("APGoals"))
                {
                    foreach (string word in selArr)
                    {
                        if (word != null && word.Trim().Length > 0)
                        {
                                                     ritem = new RadListBoxItem((string)goalsMap[word], word);
                                ctl.Items.Add(ritem);
                                keysin.Add(word);
                 
                        }
                    }

                    setGoalsInfo(val);//for populating left List Box
                }
                else if (ctl.ID.Equals("RStrategies"))
                {
                    foreach (string word in selArr)
                    {
                        if (word != null && word.Trim().Length > 0)
                        {
                                                   ritem = new RadListBoxItem((string)strategiesMap[word], word);
                                ctl.Items.Add(ritem);
                                keysin.Add(word);
                    
                        }
                    }

                    setStrategiesInfo(val);//for populating left List Box

                }

            }

    protected void setGoalsInfo(string val)
            {
                getList(LAPGoals, agency, val);
            }

            protected void setStrategiesInfo(string strsval)
            {
                getStrategise();
                string[] strategiesArray = strStrategiesInfo.Split('@');
                updateStrategiesListControl(strategiesArray, strsval, LStrategies);
                LStrategies.DataBind();

            }

            protected void getStrategise()
            {
                StringBuilder strBSkeys = new StringBuilder();
                foreach (DictionaryEntry skeys in strategiesMap)
                {
                    if (strBSkeys.Length <= 0)
                        strBSkeys.Append(skeys.Key);
                    else
                        strBSkeys.Append("@" + skeys.Key);
                }
                strStrategiesInfo = strBSkeys.ToString();
            }

    protected void getList(RadListBox radAPGoals, string sagency, string strsel)
            {
                RadListBoxItem item = null;
                //List<UserAddress> user_address_list = new List<UserAddress>();
                string[] goalsArray = strGoalsInfo.Split('@');
                updateListControl(goalsArray, strsel, radAPGoals);
                radAPGoals.DataBind();
            }

           

    not sure, where the issue would be.

Register for webinar
3 posts, 0 answered