Hello,
I am in the process of migrating some combo boxes that used to be data source driven to be populated from a web service. I am facing a scenario where I need to force the combo box to load by calling ComboBox.DataBind() in the code behind. However, following the call the ComboBox contains no data!
I have tried searching for a solution and I have referred to the documentation but I can't find anything that works. I should mention that the combo box is populated if the user interacts with it so it is configured correctly, the web service is returning data and so on.
I have tried experimenting with different values for EnableLoadOnDemand and EnableAutomaticLoadOnDemand but no luck!
Any help would be appreciated, so thanks in advance.
John.
5 Answers, 1 is accepted

By the way, I have tried calling the requestItems method on the RadCombo box in the OnClientLoad() handler. However, there are no items. But, if I call combo.showDropDown() instead then the items appear.
<script type="text/javascript">
function OnClientLoadHandler(sender) {
var combo = sender;
combo.requestItems();
var items = combo.get_items();
for (var i = 0; i < items.get_count() ; i++) {
console.log(items.getItem(i).get_text());
}
}
</script>
In order to trigger the requestItems event you should pass an empty string as a paramenter. Please consider the following implementation:
<script type=
"text/javascript"
>
function
OnClientLoadHandler(sender) {
var
combo = sender;
combo.requestItems(
""
);
......................
}
</script>
Regards,
Nencho
Telerik

Hi Nencho,
Thanks for your reply. We have tried what you have suggested, that is making the following call.
combo.requestItems("");
It seems that this will force the combo box to reload fully. However, the items are not available at the appropriate point in the page life cycle for us. So, it doesn't really solve our problem because what we need is to, as per my original post, to be able to
"force the combo box to load by calling ComboBox.DataBind() in the code behind."
Is there any way that this can be achieved? Please let me know if you need any additional information.
Thanks,
John.
I am afraid that the DataBind method will push the control to request the data, only if a Declarative DataSource binding approach is used for population with data. In addition, if the LoadOnDemand mechanism is used - the Items are not accessible on the server, as specified in the following documentation article:
http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/troubleshooting/radcombobox-items-are-not-accessible-on-the-server-side-when-loading-them-on-demand
Regards,
Nencho
Telerik

OK. That's a pity. We will have to work around this somehow.
Thanks anyway.