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
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
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.
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
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
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