This is the demo page. The important things to notice are:
1) ViewState is disabled on the page
2) When you hit submit the page either crashes or is ok depending on things mentioned below:
a) The code works fine if 2010 Q2 .NET 4.0 controls are referenced
b)The code crashes if 2011 Q1 .NET 4.0 controls are referenced (I upgraded in order to fix IE9 issues)
c) adding the commented line "//rcbCustomerCategory.ClearSelection(); " fixes the problem for 2011 Q1 controls.
I was aware of this issue with older controls. There were cases that I had to add "ClearSelection" but in most stituation I had no issue. This example code worked (for a long time) before it started experiencing problems (after an upgrade to 2011 Q1).
Also, this is just one example. I got this error in few places (probably all similar, not exact - some combos were populated via a web service for example).
This is the markup:
This is the code:
This is the error message:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Selection out of range
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Selection out of range
Parameter name: value
Source Error:
Line 17: rcbCustomerCategory.DataTextField = "Name";
Line 18: rcbCustomerCategory.DataValueField = "Id";
Line 19: rcbCustomerCategory.DataBind();
Line 20: rcbCustomerCategory.Items.Insert(0, new RadComboBoxItem("", "0"));
Line 21: }
Source File: C:\Projects\KJRB\Experiments\RadComboClearItems\DefaultPage.aspx.cs Line: 19
Stack Trace:
[ArgumentOutOfRangeException: Selection out of range
Parameter name: value]
Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource) +299
Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data) +299
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e) +661
Telerik.Web.UI.RadComboBox.PerformSelect() +21
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
Telerik.Web.UI.RadComboBox.DataBind() +38
RadComboClearItems.DefaultPage.Page_Load(Object sender, EventArgs e) in C:\Projects\KJRB\Experiments\RadComboClearItems\DefaultPage.aspx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207