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

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

5 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 09 Mar 2016, 10:02 AM

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!

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 14 Mar 2016, 06:11 AM
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.
0
Andy
Top achievements
Rank 1
answered on 17 Mar 2016, 08:08 PM

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.

0
Kostadin
Telerik team
answered on 22 Mar 2016, 09:13 AM
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.
0
Andy
Top achievements
Rank 1
answered on 22 Mar 2016, 02:01 PM

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

0
Kostadin
Telerik team
answered on 25 Mar 2016, 06:55 AM
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.
Tags
Grid
Asked by
Andy
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Andy
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or