ArgumentOutOfRangeException from Telerik.Web.UI.RadComboBox.PerformDataBinding()

4 posts, 0 answers
  1. Song
    Song avatar
    2 posts
    Member since:
    May 2014

    Posted 11 May Link to this post

    ArgumentOutOfRangeException from Telerik.Web.UI.RadComboBox.PerformDataBinding()

    My project using RadComboBox control throws exception below. The exception occurs intermittently and randomly. That is, it happens for the same user some times.

    Exception below:
    1) Exception Information
    *********************************************
    Exception Type: System.ArgumentOutOfRangeException
    Message: Selection out of range
    Parameter name: value
    Data: System.Collections.ListDictionaryInternal
    TargetSite: Void PerformDataBinding(System.Collections.IEnumerable)
    HelpLink:
    Source: Telerik.Web.UI

    StackTrace Information
    *********************************************
       at Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource)
       at Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e)
       at Telerik.Web.UI.RadComboBox.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at Telerik.Web.UI.RadComboBox.DataBind()
       at xxx.Default.Page_Load(Object sender, EventArgs e) in d:\xxx\Default.aspx.cs:line 34
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       
    Assembly Information:
        Assembly Telerik.Web.UI, Version=2014.3.1024.40, Culture=neutral, PublicKeyToken=121fae78165ba3d
        
    Project Information:    
        ASP.NET, .NET 4.6

    Telerik.Web.UI.RadComboBox Source code:
    protected override void PerformDataBinding(IEnumerable dataSource)
        {
          base.PerformDataBinding(dataSource);
          if (!string.IsNullOrEmpty(this.cachedSelectedValue))
          {
            RadComboBoxItem itemByValue = this.FindItemByValue(this.cachedSelectedValue);
            if (itemByValue == null)
              throw new ArgumentOutOfRangeException("value", "Selection out of range");
            int num = this.Items.IndexOf(itemByValue);
            if (this.cachedSelectedIndex != -1 && this.cachedSelectedIndex != num)
              throw new ArgumentOutOfRangeException("value", "SelectedIndex and SelectedValue are mutually exclusive");
            this.SelectedIndex = num;
            this.cachedSelectedValue = (string) null;
            this.cachedSelectedIndex = -1;
          }
          else if (this.cachedSelectedIndex != -1)
          {
            this.SelectedIndex = this.cachedSelectedIndex;
            this.cachedSelectedIndex = -1;
          }
          this.UpdateFromCachedValueIndex();
        }   

    Any idea to fix this?
  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    287 posts

    Posted 14 May Link to this post

    Hi Songxun,

    I would suggest you to move your custom logic that you currently have within the PerformDataBinding() method to the DataBound RadComboBox event handler.

    Regards,
    Veselin Tsvetanov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Song
    Song avatar
    2 posts
    Member since:
    May 2014

    Posted 14 May in reply to Veselin Tsvetanov Link to this post

    Hi Veselin,

    That is source code from Telerik, not my code, as mentioned on the opening thread.

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    287 posts

    Posted 17 May Link to this post

    Hi Songxun,

    This error reports that there was no item in the RadComboBox items collection, matching the saved (cached on on the postback) item. The reason for the above could be the fact that at the moment of setting the selected item, the RadComboBox items collection is still empty or it has the wrong items loaded. This could be caused even by slow / terminated internet connection. 

    Regards,
    Veselin Tsvetanov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top