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

[Solved] No datasource set for my combo box

3 Answers 285 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 03 Apr 2008, 05:24 PM
Hello guys,


I have a problem with the Prometheus combobox when trying to set a datasource dynamically.  Here how I'm set up:  I have a combo box that is part of an update panel and the combo box list of items can be very very long (many thousands items).  Since I dont want to transfer all these items (accessed by web service) and set it to the combobox datasource, I'm trying to set the datasource in the OnItemsRequested server side method when the user type 3 or more charaters in the combobox (the allow custom text is set to true and when there is 3 characters or more that are typed, in the OnItemsRequested method I call the web service and set the datasource).

The server side code that set the datasource id very simple, it looks like this:

try
{
      RadComboBox combo = (RadComboBox)o;
      combo.Items.Clear();
      conditionDTO[] dtos = searchConditions(e.Text);
       if (dtos != null)
       {
            foreach (conditionDTO dto in dtos)
            {
                RadComboBoxItem item = new RadComboBoxItem(dto.name);
                item.Value = dto.code.ToString();
                combo.Items.Add(item);
              }
        }

        combo.DataSource = dtos;
        combo.DataBind();
        ((UpdatePanel)Page.FindControl("UpdatePanelPop")).Update();
}




I make a call to the web service, set the datasource to the combobox, call databind and update my update panel. On the UI, the dropdown contains the proper items, but if I select one from the list and do a callback,  the SelectedItem on the combobox is always null (and the combobox datasource also).

Here's what the combobox definition looks like:

<telerik:RadComboBox Width="239px" Height="200px" EnableEmbeddedSkins="False" ID="selNoBlankPatientConditions" AllowCustomText="true" runat="server" DataTextField="name" DataValueField="code" EnableLoadOnDemand="true" MarkFirstMatch="True" MaxLength="50" OnItemsRequested="conditions_ItemsRequested" Text="Type or select your condition here..." >
     <CollapseAnimation Duration="200" Type="OutQuint" />
     <ExpandAnimation Type="OutQuart" />
</telerik:RadComboBox>


I really need help on this one!

Thx,
Phil

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 07 Apr 2008, 12:22 PM
Hi Philippe,

Try using RadComboBox.Text and RadComboBox.SelectedValue to get the Text and Value of the currently selected item, which is added via the Load-On-Demand mechanism.

Please, let me know how it goes.

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Philippe
Top achievements
Rank 1
answered on 07 Apr 2008, 06:03 PM
Hi,

I tried it and it works properly, but I don't understand why the datasource is never set the way I set it.  Anyway, your solution will do the job.

Thx a lot,
Phil
0
Simon
Telerik team
answered on 09 Apr 2008, 12:25 PM
Hello Philippe,

The data source set in the ItemsRequested and all the items which are added at this moment are not available on subsequent postbacks/callbacks on the server. This is due to the Load-On-Demand mechanism - items do not persist on the server.

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Philippe
Top achievements
Rank 1
Answers by
Simon
Telerik team
Philippe
Top achievements
Rank 1
Share this question
or