Product Bundles
DevCraft
All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
Web
Mobile
Document Management
Desktop
Reporting
Testing & Mocking
CMS
UI/UX Tools
Debugging
Free Tools
Support and Learning
Productivity and Design Tools
<%@ WebService Language="C#" CodeBehind="~/App_Code/Products.cs" Class="Products" %>
using
System;
System.Collections.Generic;
System.Configuration;
System.Data;
System.Data.SqlClient;
System.Web;
System.Web.Script.Services;
System.Web.Services;
Telerik.Web.UI;
[ScriptService]
public
class
Products : WebService
{
[WebMethod]
RadComboBoxData GetCompanyNames(RadComboBoxContext context)
string
sql =
"SELECT * from Customers WHERE CompanyName LIKE @text + '%'"
;
SqlDataAdapter adapter =
new
SqlDataAdapter(sql,
ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"
].ConnectionString);
DataTable data =
DataTable();
adapter.SelectCommand.Parameters.AddWithValue(
"@text"
, context.Text);
adapter.Fill(data);
List<RadComboBoxItemData> result =
List<RadComboBoxItemData>(context.NumberOfItems);
RadComboBoxData comboData =
RadComboBoxData();
try
int
itemsPerRequest = 10;
itemOffset = context.NumberOfItems;
endOffset = itemOffset + itemsPerRequest;
if
(endOffset > data.Rows.Count)
endOffset = data.Rows.Count;
}
(endOffset == data.Rows.Count)
comboData.EndOfItems =
true
else
false
result =
List<RadComboBoxItemData>(endOffset - itemOffset);
for
(
i = itemOffset; i < endOffset; i++)
RadComboBoxItemData itemData =
RadComboBoxItemData();
itemData.Text = data.Rows[i][
"CompanyName"
].ToString();
itemData.Value = data.Rows[i][
result.Add(itemData);
(data.Rows.Count > 0)
comboData.Message = String.Format(
"Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>"
, endOffset.ToString(), data.Rows.Count.ToString());
comboData.Message =
"No matches"
catch
(Exception e)
comboData.Message = e.Message;
comboData.Items = result.ToArray();
return
comboData;