Selection out of range on formview

8 posts, 0 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 20 Apr 2011 Link to this post

    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
  2. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 21 Apr 2011 Link to this post

    bump
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 26 Apr 2011 Link to this post

    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

    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.

  5. Darren
    Darren avatar
    20 posts
    Member since:
    Sep 2011

    Posted 11 Sep 2012 Link to this post

    I would like to see the ComboBox not throw the exception in this case...
  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 17 Sep 2012 Link to this post

    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
    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.
  7. Darren
    Darren avatar
    20 posts
    Member since:
    Sep 2011

    Posted 11 Dec 2012 Link to this post

    Hi Jon,

    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;
            }
        }
    }
  8. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 31 Jan 2013 Link to this post

    Darren, you are a god-send. If I could rep you, I would!
  9. Darren
    Darren avatar
    20 posts
    Member since:
    Sep 2011

    Posted 01 Feb 2013 Link to this post

    Hee hee hee! :D

    Thanks man!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017