This example demonstrates how to bind programatically RadComboBox in load on demand scenario.
Also when user types it in the input field a callback is made to the server in order to request all customer names that match the typed text.
protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
using (NorthwindReadOnlyDataContext northwindEntities = new NorthwindReadOnlyDataContext())
{
var allCustomers = northwindEntities.Customers.
OrderBy(i => i.ContactName);
if (!String.IsNullOrEmpty(e.Text))
{
allCustomers = northwindEntities.Customers.Where(i =>
i.ContactName.Contains(e.Text.Trim()))
.OrderBy(i => i.ContactName);
}
var customers = allCustomers.Skip(e.NumberOfItems).Take(10);
RadComboBox2.DataSource = customers;
RadComboBox2.DataBind();
int endOffset = e.NumberOfItems + customers.Count();
int totalCount = allCustomers.Count();
if (endOffset == totalCount)
e.EndOfItems = true;
e.Message = String.Format("Items 1-{0} out of {1}",
endOffset, totalCount);
}
}