Set a value while load on demand by web service

2 posts, 0 answers
  1. Nessi
    Nessi avatar
    6 posts
    Member since:
    Jun 2015

    Posted 01 Sep 2015 Link to this post


    I'm using multiple RadComboBoxes that are filled by a web service like this:

    1.<telerik:RadComboBox runat="server" ID="Value" Width="300px" EnableLoadOnDemand="true" OnClientItemsRequesting="LookupItemRequesting" OnItemsRequested="Value_OnItemsRequested" AutoPostBack="False">
    2.  <WebServiceSettings Path="/Handlers/IdmpService.asmx" Method="LoadDropDownValues" UseHttpGet="true"></WebServiceSettings>

    The method to fill the combobox looks like this:

    02.[ScriptMethod(UseHttpGet = true)]
    03.public RadComboBoxData LoadDropDownValues(RadComboBoxContext context)
    05.  var res = new RadComboBoxData();
    06.  var itemType = context["ItemType"].AsString();
    07.  var valueProperty = context["ValueProperty"].AsString();
    08.  ...
    09.  var result = new List<RadComboBoxItemData>();
    10.  try
    11.  {
    12.    ...
    13.    foreach (Dictionary<string, object> item in items)
    14.    {
    15.      // process items...
    16.      result.Add(new RadComboBoxItemData { Value = "some integer id", Text = string.Join(", ", string.Format(displayFormat, values.ToArray())) });
    17.    }
    18.  }
    19.  catch (Exception ex)
    20.  {
    21.    result = new List<RadComboBoxItemData> { new RadComboBoxItemData { Value = "", Text = ex.Message } };
    22.  }
    23.  res.Items = result.ToArray();
    24.  return res;

    Together with quite a few other Telerik controls this is a form used to view/edit data, so I need to set a specific value for thie ComboBox. How can I assign a value to the ComboBox to make sure that when I save the whole data, I can read the correct value from the ComboBox?



  2. Nencho
    Nencho avatar
    1664 posts

    Posted 04 Sep 2015 Link to this post

    Hello Nessi,

    Could you please elaborate a bit more on your scenario, so we could suggest you the proper approach for your case. If you simply get some value, in order to set it as selected for the RadComboBox (that you have demonstrated above) you can use the set_text() on the control, as demonstrated below:

    <script type="text/javascript">
               function OnClientLoad(sender) {
                   sender.set_text("The Item To Select");

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top