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

Error : Selection out of range Parameter name : Value

2 Answers 91 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
mathieu emptoz
Top achievements
Rank 1
mathieu emptoz asked on 05 Jul 2012, 09:16 AM
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 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 09 Jul 2012, 03:07 PM
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.
0
mathieu emptoz
Top achievements
Rank 1
answered on 10 Jul 2012, 08:25 AM
Thanks for response !

It was a problem with my page !
A bad DataBind...
Tags
ComboBox
Asked by
mathieu emptoz
Top achievements
Rank 1
Answers by
Peter
Telerik team
mathieu emptoz
Top achievements
Rank 1
Share this question
or