RadCombobox with EnableLoadOnDemand in EditForm throws "Selection out of range" exception

6 posts, 0 answers
  1. Andy
    Andy avatar
    54 posts
    Member since:
    Jun 2009

    Posted 09 Mar Link to this post

    Hello,

    Is there some working sample of a  RadGrid with EditFormType = "WebUserControl" and where this UserControl contains a combobox with EnableLoadOnDemand = true? The issue I'm facing in this scenario is that when I try to set selectedValue of the combo in code behind using OnDataBinding handler or in markup using <%#%> tags, inside the user control, I get "selection out of range" exception when radgrid is binding. In other threads it's suggested to set RadComboBox.SelectedValue in RadGrid.ItemDataBound handler, but I would rather keep initialization inside the user control.

    Thank you!

  2. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 14 Mar Link to this post

    Hello Andy,

    You can try to use the binding expressions with the Text property of the combo instead. For a general sample with WebUserControl editing, you can check the following live sample:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultcs.aspx

    Regards,
    Eyup
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy
    Andy avatar
    54 posts
    Member since:
    Jun 2009

    Posted 17 Mar Link to this post

    Hi Eyup,

    Thank you for the suggestion. Unfortunately I need to have SelectedValue set for the combobox. The only workable solution I was able to find is to assign it in ItemDataBound handler.

  5. Kostadin
    Admin
    Kostadin avatar
    1709 posts

    Posted 22 Mar Link to this post

    Hi Andy,

    The reason for this exception is that the ComboBox is still not bind. I am afraid you need to use ItemDataBound event handler to select a ComboBox value. Another possible solution is to use a server binding where the control is bind initially and you can select a value by using an Eval expression.

    Regards,
    Kostadin
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Andy
    Andy avatar
    54 posts
    Member since:
    Jun 2009

    Posted 22 Mar Link to this post

    Hi Kostadin,

    Thank you for reply! Binding with Eval expression also throws "Selection out of range" exception, otherwise I'd go with that. It's quite weird that even though RadComboBox is set to load items dynamically using ItemsRequested event, it still checks if selected value being assigned exists in items collection.

    Regards,

    Andy

  7. Kostadin
    Admin
    Kostadin avatar
    1709 posts

    Posted 25 Mar Link to this post

    Hello Andy,

    Note that SelectedValue should be used in case you are binding the grid on the server and not on demand. I would recommend you to examine the following live example which demonstrates two approaches to pre-select a value of the ComboBox.

    Regards,
    Kostadin
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017