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

The server method "[webmethod name]" failed

0 Answers 224 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 18 Mar 2009, 10:49 PM
**** Disregard, I've found the issue:  The asmx page was not pointing to the correct class.******

I can't get your combo to populate from web service and the error message is useless.  It does not even appear to call the webmethod. 

ascx
<telerik:RadComboBox ID="rcbRevenueType" EnableVirtualScrolling="true" EnableViewState="false" 
                        AllowCustomText="true" ShowMoreResultsBox="false" ShowToggleImage="true" EnableItemCaching="true" 
                        MaxHeight="150px" MarkFirstMatch="True" ChangeTextOnKeyBoardNavigation="true" EnableScreenBoundaryDetection="true" 
                        EnableTextSelection="true" ShowDropDownOnTextboxClick="true" ShowWhileLoading="true" 
                        runat="server" EnableLoadOnDemand="true" EnableEmbeddedSkins="false" Skin="CienaComboBox" 
                        Width="200px">  
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        <WebServiceSettings Path="~/DataLookupService.asmx" Method="GetAllRevenueTypes" /> 
                    </telerik:RadComboBox> 


asmx.cs
[WebMethod]  
        public RadComboBoxData GetAllRevenueTypes(RadComboBoxContext context)  
        {  
            LookupDAO lookup = new LookupDAO();  
            DataTable dt = lookup.GetActiveRevenueTypesDT();  
            DataView dv = dt.DefaultView;  
            dv.Sort = "Name ASC";  
            return FormatItems(dv, context, "Name", "RevenueType_ID", 8);  
 
        }  
 
        public RadComboBoxData FormatItems(DataView dv, RadComboBoxContext context, string text, string value, int requestcount)  
        {  
            List<RadComboBoxItemData> result = null;  
            // Create a RadComboBoxData object to pass virtual scrolling information  
            RadComboBoxData comboData = new RadComboBoxData();  
            // calculate the number of records we need  
            // based on the current number of items  
            int itemsPerRequest = requestcount;  
            int itemOffset = context.NumberOfItems;  
            int endOffset = itemOffset + itemsPerRequest;  
            // adjust endOffset if there are not enough rows  
            if (endOffset > dv.Count)  
            {  
                endOffset = dv.Count;  
            }  
            // set EndOfItems to reflect whether we are supplying the last items  
            if (endOffset == dv.Count)  
            {  
                comboData.EndOfItems = true;  
            }  
            else  
            {  
                comboData.EndOfItems = false;  
            }  
            // create the list to hold the items we will return  
            result = new List<RadComboBoxItemData>(endOffset - itemOffset);  
            // iterate through the rows of the table, creating and adding items  
            for (int i = itemOffset; i < endOffset; i++)  
            {  
                RadComboBoxItemData itemData = new RadComboBoxItemData();  
                itemData.Text = dv[i][text].ToString();  
                itemData.Value = dv[i][value].ToString();  
                result.Add(itemData);  
            }  
            comboData.Items = result.ToArray();  
            return comboData;  
 
        } 

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Dave
Top achievements
Rank 1
Share this question
or