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

Bug in combobox online Demo

1 Answer 85 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Stanley
Top achievements
Rank 1
Stanley asked on 22 Jul 2011, 08:23 AM
Hi all,

According your demo on usibng web services to load data on demand:

http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx


if I remove the 'static' code from the method in the code behind CS page I get the error :

"The server method has failed' as a popup box.

Here is my code behind:

public const int ItemsPerRequest = 10;
 
       [WebMethod]
       public  RadComboBoxData GetDealNumbers(RadComboBoxContext context)
       {
           DataTable data = GetData(context.Text);
            
           RadComboBoxData comboData = new RadComboBoxData();
           int itemOffset = context.NumberOfItems;
           int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
           comboData.EndOfItems = endOffset == data.Rows.Count;
 
 
           List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset);
 
 
           for (int i = itemOffset; i < endOffset; i++)
           {
               RadComboBoxItemData itemData = new RadComboBoxItemData();
               itemData.Text = data.Rows[i]["DealNo"].ToString();
               itemData.Value = data.Rows[i]["DealNo"].ToString();
               result.Add(itemData);
           }
                       
           comboData.Message = GetStatusMessage(endOffset, data.Rows.Count);
 
 
           comboData.Items = result.ToArray();
           return comboData;
 
 
       }
 
 
       public  DataTable GetData(string text)
       {
           
           SqlDataAdapter adapter = new SqlDataAdapter("SELECT new_name as 'DealNo' from new_dealtracking WHERE new_name  LIKE @text + '%'", Properties.Settings.Default.MSCRMConnectionString);
            
           
            
           adapter.SelectCommand.Parameters.AddWithValue("@text", text);
 
 
           DataTable data = new DataTable();
           adapter.Fill(data);
 
 
           return data;
       }
 
 
       private  string GetStatusMessage(int offset, int total)
       {
           if (total <= 0)
               return "No matches";
            
           return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
       }
:

My aspx code is:

<telerik:RadComboBox ID="RadComboBox4" runat="server" Width="157px" Height="150px"
               EmptyMessage="Select a Deal" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
               EnableVirtualScrolling="true">
            
               <WebServiceSettings Method="GetDealNumbers" Path="Custom_DealUI.aspx" />
           </telerik:RadComboBox>

Why is this the case??

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 22 Jul 2011, 01:51 PM
Hello Stanley,

The reason it doesn't work when you remove the static qualifier on the method is because you're using the Page Methods technique, not a Web Service, even though you set it up in the WebServiceSettings tag.

The real Web Service example is the third one from the bottom, which you'll notice from the .asmx extension used in the Path.

I hope that helps.
Tags
ComboBox
Asked by
Stanley
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Share this question
or