Declined
Last Updated: 06 Feb 2023 10:53 by ADMIN
Camputaro
Created on: 30 Jan 2023 14:43
Category: UI for ASP.NET AJAX
Type: Feature Request
0
ArgumentOutOfRange Add Control ID

Hello,

Can you please add the control ID to this error so the affected control can be easily identified?  Right now, if you have a page with multiple combo boxes, it is extremely time consuming to locate the one with the issue.

Thank you,
DJ

--

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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[ArgumentOutOfRangeException: Selection out of range
Parameter name: value]
   Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource) +339
   Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e) +1196
   Telerik.Web.UI.RadComboBox.PerformSelect() +34
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +134
   Telerik.Web.UI.RadComboBox.OnPreRender(EventArgs e) +57
   System.Web.UI.Control.PreRenderRecursiveInternal() +200
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Control.PreRenderRecursiveInternal() +297
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7474

 

1 comment
ADMIN
Attila Antal
Posted on: 06 Feb 2023 10:53

Hello Camputaro,

Changing the generic Exceptions is not our best practice. Instead, we suggest that you always sanitize the ASP.NET/C#/VB code to avoid selecting array elements that do not exist at a certain index or are not present on the list at all.

If you are using the Inline Expressions to Bind() values to the SelectedValue property, you will need to ensure that any data coming from the database is also present in the ComboBox.

<telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight" SelectedValue='<%# Bind("SomeField") %>'>
</telerik:RadComboBox>

 

If the database may contain values that are not present in the Combo's source/items list, you should manually select the items.

<telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight">
</telerik:RadComboBox>

 

C#

string clientName = "Josh";

RadComboBoxItem comboItem = RadComboBox1.FindItemByText(clientName);

if(comboItem != null)
{
    comboItem.Selected = true;
}

 

By following the best practices of programming, you will never have to deal with the ArgumentOutOfRangeException.

 

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.