Hi guys, I cant get the databinding to work, either on webservice or WCF. I have tried binding to both local webservice in same project and deployed webservice on remote server (both functioning), but when querying for data all I get is: "The server method 'GetKeywordList' failed"
(GetKeywordList is the name of the webmethod / operationcontract)
Any good advice?
Best regards,
Kim
(GetKeywordList is the name of the webmethod / operationcontract)
Any good advice?
Best regards,
Kim
5 Answers, 1 is accepted
0
Hi Klestrup,
Thank you for your feedback.
I am sending you a sample project where RadAutoCompleteBox is populated via web services.
Please download it, add references to Telerik assemblies and use the attached Northwind database to test the control binding.
Feel free to contact me if you have additional questions.
All the best,
Kalina
the Telerik team
Thank you for your feedback.
I am sending you a sample project where RadAutoCompleteBox is populated via web services.
Please download it, add references to Telerik assemblies and use the attached Northwind database to test the control binding.
Feel free to contact me if you have additional questions.
All the best,
Kalina
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

Darren
Top achievements
Rank 2
answered on 20 Sep 2012, 08:18 PM
This is great sample code. I see the web service returns an AutoCompleteBoxData node which has a Text and a Value property. I'm trying to achieve something like this (http://demos.telerik.com/aspnet-ajax/autocompletebox/examples/templates/defaultcs.aspx ) where templates are used. Using templates I need to return more than just test/value. I need to return about 5 values. How could I modify this sample to accomplish this?
Thanks!
Thanks!
[WebMethod]
public
AutoCompleteBoxData GetCompanyNames(RadAutoCompleteContext context)
{
string
sql =
"SELECT * from Customers WHERE CompanyName LIKE '"
+ context.Text +
"%'"
;
SqlDataAdapter adapter =
new
SqlDataAdapter(sql,
ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString1"
].ConnectionString);
DataTable data =
new
DataTable();
adapter.Fill(data);
List<AutoCompleteBoxItemData> result =
new
List<AutoCompleteBoxItemData>();
foreach
(DataRow row
in
data.Rows)
{
AutoCompleteBoxItemData childNode =
new
AutoCompleteBoxItemData();
childNode.Text = row[
"CompanyName"
].ToString();
childNode.Value = row[
"CustomerID"
].ToString();
result.Add(childNode);
}
AutoCompleteBoxData res =
new
AutoCompleteBoxData();
res.Items = result.ToArray();
return
res;
}
0
Hi Darren,
Please take a look at the GetChildren method implementation in the demo code.
You can add Attributes to every AutoCompleteBoxItemData instance:
Then in markup you can implement a Client-side template.
All the best,
Kalina
the Telerik team
Please take a look at the GetChildren method implementation in the demo code.
You can add Attributes to every AutoCompleteBoxItemData instance:
[WebMethod]
public
static
AutoCompleteBoxData GetChildren(
object
context)
{
string
searchString = ((Dictionary<
string
,
object
>)context)[
"Text"
].ToString();
DataTable data = GetChildNodes(searchString);
List<AutoCompleteBoxItemData> result =
new
List<AutoCompleteBoxItemData>();
foreach
(DataRow row
in
data.Rows)
{
AutoCompleteBoxItemData childNode =
new
AutoCompleteBoxItemData();
childNode.Text = row[
"ContactName"
].ToString();
childNode.Attributes.Add(
"ContactTitle"
, row[
"ContactTitle"
].ToString());
childNode.Attributes.Add(
"City"
, row[
"City"
].ToString());
childNode.Attributes.Add(
"Country"
, row[
"Country"
].ToString());
childNode.Attributes.Add(
"Phone"
, row[
"Phone"
].ToString());
childNode.Attributes.Add(
"Photo"
, System.Web.VirtualPathUtility.ToAbsolute(
"~/Img/Northwind/Customers/"
+ row[
"CustomerID"
].ToString() +
".jpg"
));
result.Add(childNode);
}
AutoCompleteBoxData res =
new
AutoCompleteBoxData();
res.Items = result.ToArray();
return
res;
}
Then in markup you can implement a Client-side template.
All the best,
Kalina
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

Vinu
Top achievements
Rank 1
answered on 10 Jan 2013, 04:15 PM
I am trying to bind a list of 3000 strings to the RadAutoCompleteBox using Web Service. I have used the sample applications attached in this thread but it keeps throwing an Error saying "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"
Here is my code:
ASPX:
<telerik:RadAutoCompleteBox runat="server" ID="radAcBxSearch">
<WebServiceSettings Path="WebService_TEST.asmx" Method="GetList" />
</telerik:RadAutoCompleteBox>
WebService_TEST.ASMX
[WebMethod]
public AutoCompleteBoxData GetList()
{
var query = ProdDbContext.Select(x => x.Name).ToList();
List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
result = new List<AutoCompleteBoxItemData>();
foreach (string str in query)
{
AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
itemData.Text = str;
itemData.Value = str;
result.Add(itemData);
}
dropDownData.Items = result.ToArray();
return dropDownData;
}
}
Here is my code:
ASPX:
<telerik:RadAutoCompleteBox runat="server" ID="radAcBxSearch">
<WebServiceSettings Path="WebService_TEST.asmx" Method="GetList" />
</telerik:RadAutoCompleteBox>
WebService_TEST.ASMX
[WebMethod]
public AutoCompleteBoxData GetList()
{
var query = ProdDbContext.Select(x => x.Name).ToList();
List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
result = new List<AutoCompleteBoxItemData>();
foreach (string str in query)
{
AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
itemData.Text = str;
itemData.Value = str;
result.Add(itemData);
}
dropDownData.Items = result.ToArray();
return dropDownData;
}
}
0

Cat Cheshire
Top achievements
Rank 1
answered on 15 Jan 2013, 12:34 PM
You can increase the max json length - http://geekswithblogs.net/frankw/archive/2008/08/05/how-to-configure-maxjsonlength-in-asp.net-ajax-applications.aspx