private const int ItemsPerRequest = 10; [WebMethod] public RadComboBoxItemData[] GetAccount(object context) { RadComboBoxContext obj = (RadComboBoxContext)context; DataTable data = GetDataAccount(obj.Text); RadComboBoxData comboData = new RadComboBoxData(); int itemOffset = obj.NumberOfItems; int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count); comboData.EndOfItems = endOffset == data.Rows.Count; List result = new List(endOffset - itemOffset); for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItemData itemData = new RadComboBoxItemData(); itemData.Value = data.Rows[i]["AccountLevelNo"].ToString(); itemData.Text = data.Rows[i]["AccountDesc3"].ToString(); itemData.Attributes.Add("Level6", data.Rows[i]["AccountDesc2"].ToString()); itemData.Attributes.Add("Level1", data.Rows[i]["AccountDesc1"].ToString()); result.Add(itemData); } comboData.Items = result.ToArray(); // comboData.Message = GetStatusMessage(endOffset, data.Rows.Count); return comboData.Items.ToArray(); } private static DataTable GetDataAccount(string text) { int accCode = 0; string query = "select COA.LevelAccountNo,COA.AccountDesc as AccountDesc3,Level1.AccountDesc as AccountDesc1, Level2.AccountDesc as AccountDesc2 from COA COA,(select LevelAccountNo,AccountDesc " + "from COA where len(LevelAccountNo)=2)as Level1,(select LevelAccountNo,AccountDesc from COA where len(LevelAccountNo)=5)as Level2 " + "where Level1.LevelAccountNo=left(COA.LevelAccountNo,2)and Level2.LevelAccountNo=left(COA.LevelAccountNo,5) and len(COA.LevelAccountNo)>6"; try { accCode = Convert.ToInt32(text); query = query + " COA.LevelAccountNo like '" + text + "%'"; } catch (Exception ex) { query = query + " COA.AccountDesc3 like '%" + text + "%'"; } SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString()); // string constr=ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlDataAdapter adapter = new SqlDataAdapter(query, con); // adapter.SelectCommand.Parameters.AddWithValue("@text", text); DataTable data = new DataTable(); adapter.Fill(data); con.Close(); return data; }
this is my web service code
Collapse | Copy Code <telerik:RadComboBox ID="cboAccount" runat="server" Height="200" Width="200" EmptyMessage="Select an Account" EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"> <HeaderTemplate> <h3>Accounts</h3> </HeaderTemplate> <ClientItemTemplate> <div> <ul> <li><span><b>Name:#= Text # </b></span></li> <li><span>Level6 #= Attributes.Level6 # </span></li> <li><span>Level1: #= Attributes.Level4 # </span></li> <li><span>Level4 #= Attributes.Level1 # </span></li> </ul> </div> <br></br> </ClientItemTemplate> <WebServiceSettings Method="GetAccount" Path="InvestmentDropDownWebService.asmx" /> </telerik:RadComboBox>
This is the first time I'm using webservice in my project. I do not know how to solve this error. If I execute aspx.cs , this works fine, and the values ββbind to the combo box. But when I bind values ββto combobox using a web service, it gives an error:
The Telerik.Web.UI.RadComboBoxContext type is not supported because it implements IDictionary.
user2851409
source share