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

Selection out of Range - Exception when binding Combobox

2 Answers 138 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andreas N.
Top achievements
Rank 2
Andreas N. asked on 14 Jul 2008, 01:19 PM
Hi,

the exception occured in Version Q1 2008 build 619.

When I run the following code twice

DataView dv2 = dt2.DefaultView;

dv2.Sort = columnName +

" ASC";

cboSBOldValue.Items.Clear();

cboSBOldValue.DataTextField = columnName;

cboSBOldValue.DataValueField = columnName;

cboSBOldValue.DataSource = dv2;

cboSBOldValue.DataBind();



I get the above mentioned exception the second time the code runs.
The content of the DataView is completely different the second time.
The exception is raised here: cboSBOldValue.DataBind();


Exception Details:
System.ArgumentOutOfRangeException was unhandled by user code
  Message="Selection out of range\r\nParametername: value"
  Source="Telerik.Web.UI"
  ParamName="value"
  StackTrace:
       bei Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource)
       bei Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data)
       bei System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       bei Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e)
       bei Telerik.Web.UI.RadComboBox.PerformSelect()
       bei System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       bei CLWorkbench.SQLBox.cboSBOldValue_ItemsRequested(Object o, RadComboBoxItemsRequestedEventArgs e) in H:\projects\ClLoader\SOURCES\CLWorkbench\CLWorkbench\SQLBox.ascx.cs:Zeile 1054.
       bei Telerik.Web.UI.RadComboBox.RaiseItemRequestEvent(RadComboBoxItemsRequestedEventArgs args)
       bei Telerik.Web.UI.RadComboBox.RaiseCallbackEvent(String eventArgument)
       bei Telerik.Web.UI.RadComboBox.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(String eventArgument)
       bei System.Web.UI.Page.PrepareCallback(String callbackControlID)
  InnerException:


Obviously the same issue was already discussed here:
http://www.telerik.com/community/forums/thread/b311D-bbgmmt.aspx

Thank you for your help

regards

Andreas

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 14 Jul 2008, 01:58 PM
Hello ,

I suggest you call cboSBOldValue.ClearSelection() method after you call cboSBOldValue.Items.Clear();

Greetings,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas N.
Top achievements
Rank 2
answered on 14 Jul 2008, 02:06 PM
Hi Rosi,

that's it!

thank you

nic77
Tags
ComboBox
Asked by
Andreas N.
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Andreas N.
Top achievements
Rank 2
Share this question
or