Error : Selection out of range Parameter name : Value

3 posts, 0 answers
  1. mathieu emptoz
    mathieu emptoz avatar
    4 posts
    Member since:
    Nov 2009

    Posted 05 Jul 2012 Link to this post

    Hi,

    I have a problem since few days with the RadCombox on LoadOnDemande.
    The load is OK, but when i select an item in the list and i post the page, i have an error message : "Selection out of range Parameter name : Value"

    I don't understand the problem, the same code worked before.

    Thanks for help

    Aspx code :
    <telerik:RadComboBox ID="MRLieu" runat="server"
              AllowCustomText="true"
              ItemRequestTimeout="1000"
              Filter="Contains"
              ShowDropDownOnTextboxClick="false"
              MinFilterLength="2"
              EnableLoadOnDemand="true"
              EnableVirtualScrolling="true"
              ShowToggleImage="false"
              OnClientFocus="ChangeOu"
              OnClientItemsRequesting="OnClientItemsRequesting">
               <webservicesettings method="GetLieu" path="~/Utils/WebService/Utils.asmx" />
    </telerik:RadComboBox>

    JS Code :
    function OnClientItemsRequesting(sender, eventArgs) {
        var context = eventArgs.get_context();
        context["coffret"] = "16";
    }
     
    function ChangeOu(sender) {
        var lieu = $find("MRech_MRLieu");
        lieu.clearSelection();
        lieu.clearItems();
      }


    C# Code WS :
    [WebMethod]
    [ScriptMethod]
    public RadComboBoxItemData[] GetLieu(object context)
    {
      IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
     
      string txt = contextDictionary["Text"].ToString();
      int coffret = Convert.ToInt32(contextDictionary["coffret"]);
     
      txt = txt.Replace("'", " ");
      txt = txt.Replace("\"", " ");
      txt = string.Concat("\"", txt, "*\"");
     
      string sql = @"MyRequest";
     
      ConnexionUtil cnnUtil = new ConnexionUtil();
      DataTable data = cnnUtil.ExecuteRequeteDataTable(sql);
     
      int itemOffset = Convert.ToInt32(contextDictionary["NumberOfItems"]);
      int endOffset = Math.Min(itemOffset + NBITEMS, data.Rows.Count);
     
      List<RadComboBoxItemData> result = new List<RadComboBoxItemData>();
      RadComboBoxItemData itemData;
      for (int i = itemOffset; i < endOffset; i++)
      {
        itemData = new RadComboBoxItemData();
        itemData.Text = data.Rows[i]["nom"].ToString();
        itemData.Value = data.Rows[i]["id"].ToString();
        result.Add(itemData);
      }
     
      data.Dispose();
      cnnUtil.Dispose();
     
      return result.ToArray();
    }
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 09 Jul 2012 Link to this post

    Hello Mathieu,

    I tested the case following your code as closely as possible, but everything worked as expected. Can you review the attached sample and let me know if I am missing something?
    (You need to type any two digits, e.g. "22", or "35" in the combobox input area.)

    Kind regards,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. mathieu emptoz
    mathieu emptoz avatar
    4 posts
    Member since:
    Nov 2009

    Posted 10 Jul 2012 Link to this post

    Thanks for response !

    It was a problem with my page !
    A bad DataBind...
Back to Top