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

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

4 Answers 335 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Song
Top achievements
Rank 1
Song asked on 11 May 2016, 10:48 AM

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?

4 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 14 May 2016, 06:51 AM
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.
0
Song
Top achievements
Rank 1
answered on 14 May 2016, 06:16 PM

Hi Veselin,

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

0
Veselin Tsvetanov
Telerik team
answered on 17 May 2016, 07:47 AM
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.
0
Tarun
Top achievements
Rank 1
answered on 27 Mar 2018, 12:54 PM

Hi,

So, is there any way we can prevent it from occurring? Probably some check anywhere?

Tags
ComboBox
Asked by
Song
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Song
Top achievements
Rank 1
Tarun
Top achievements
Rank 1
Share this question
or