Hi,
I am getting a selection out of range when binding to a datasource in a formview. This happens on occasion if the previously saved ID for say a company on the formview no longer exists in the company datasource.
That is fine and I expect an exception to be raised as the company ID does indeed not exist in the datasource.
I need to be able to intercept that exception with a try / catch and then manually change the empty item text to something like "Invalid company value". The user can then select a different company.
Because the binding is handled by the formview I'm not sure where to have the try/catch...
Any suggestions?
Regards,
Jon
I am getting a selection out of range when binding to a datasource in a formview. This happens on occasion if the previously saved ID for say a company on the formview no longer exists in the company datasource.
That is fine and I expect an exception to be raised as the company ID does indeed not exist in the datasource.
I need to be able to intercept that exception with a try / catch and then manually change the empty item text to something like "Invalid company value". The user can then select a different company.
Because the binding is handled by the formview I'm not sure where to have the try/catch...
Any suggestions?
Regards,
Jon
7 Answers, 1 is accepted
0

Jon
Top achievements
Rank 1
answered on 21 Apr 2011, 03:16 PM
bump
0
Hi Jon,
Did you set the SelectedValue of RadComboBox declaratively?
If so, I may suggest you to set it in the code behind on some event which occurs after the RadComboBox databinding.
You may add a check whether the "ID" column exists and set the SelectedValue accordingly.
Regards,
Helen
the Telerik team
Did you set the SelectedValue of RadComboBox declaratively?
If so, I may suggest you to set it in the code behind on some event which occurs after the RadComboBox databinding.
You may add a check whether the "ID" column exists and set the SelectedValue accordingly.
Regards,
Helen
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Darren
Top achievements
Rank 1
answered on 11 Sep 2012, 03:11 PM
I would like to see the ComboBox not throw the exception in this case...
0
Hi Darren,
In order to help you we will need some more details.
Could you please explain in more details your implementation and paste some working code here?
How exactly do you bind RadComboBox?
What is the exact exception that you receive?
Kind regards,
Kalina
the Telerik team
In order to help you we will need some more details.
Could you please explain in more details your implementation and paste some working code here?
How exactly do you bind RadComboBox?
What is the exact exception that you receive?
Kind regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Darren
Top achievements
Rank 1
answered on 11 Dec 2012, 09:22 PM
Hi Jon,
Try this and see how it works for you:
Try this and see how it works for you:
[ToolboxData("<{0}:RadComboBoxEx runat='server'></{0}:RadComboBoxEx>")]
public class RadComboBoxEx : RadComboBox
{
public RadComboBoxEx()
: base()
{
}
protected override void PerformDataBinding(System.Collections.IEnumerable dataSource)
{
try
{
base.PerformDataBinding(dataSource);
}
catch(ArgumentOutOfRangeException ex)
{
//Swallow this exception...
}
catch(Exception ex)
{
throw ex;
}
}
}
0

ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
answered on 31 Jan 2013, 03:56 PM
Darren, you are a god-send. If I could rep you, I would!
0

Darren
Top achievements
Rank 1
answered on 01 Feb 2013, 08:26 PM
Hee hee hee! :D
Thanks man!
Thanks man!