Click here to Skip to main content
16,001,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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<radcomboboxitemdata> result = new List<radcomboboxitemdata>(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


XML
<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 Rad combo box html code and call web service
After running the project i will recieved this error please help me
The type Telerik.Web.UI.RadComboBoxContext is not supported because it implements IDictionary.
Posted
Comments
Arsalaan Ahmed 5-Oct-13 9:52am    
Orginal Griff Sergey please Help me.....

1 solution

I have gone through the same problem. I cope with this issue as follows. Change your line of

C#
[WebMethod]

to

C#
[WebMethod(EnableSession = true)]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]

And also, Add an attribute of

C#
WebServiceSettings-UseHttpGet="true"

in your ASPX code of RadCombo Box. My problem was solved after doing all that. Hope it will work for you as well! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900