New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Client-side Binding

Web Service binding

The items in the SearchContext drop-down can be also loaded from Web Service by setting the WebServiceSettings for SearchContext and the appropriate path and name. In this case one can assign the ImageUrl of an item directly in the service method as below:

 <telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox4"  DataSourceID="SqlDataSource3" Label="Three"
             DataTextField="LastName" DataValueField="FirstName" DataContextKeyField="EmployeeID" >
    <DropDownSettings Height="400" Width="300" />
    <Localization LoadingItemsMessage="Loading Items" />
    <SearchContext  >
        <WebServiceSettings Path="ContextService.svc" Method="GetContextResults"/>

public SearchContextItemData[] GetContextResults(object context)
    List<SearchContextItemData> result = new List<SearchContextItemData>();

    for (int i = 0; i < 10; i++)
        SearchContextItemData itemData = new SearchContextItemData();
        itemData.Text = "Item" + i.ToString();
        itemData.Key = i.ToString();
        itemData.ImageUrl = "small.png";

    return result.ToArray();

<OperationContract> _
Public Function GetContextResults(context As Object) As SearchContextItemData()
    Dim result As New List(Of SearchContextItemData)()

    For i As Integer = 0 To 9
        Dim itemData As New SearchContextItemData()
        itemData.Text = "Item" + i.ToString()
        itemData.Key = i.ToString()
        itemData.ImageUrl = "small.png"

    Return result.ToArray()
End Function

OData binding

When SearchContext is bound to RadODataDataSource control, its DataModelID property should be set to a Model ID from the data source. In such scenario in a similar manner as when the control is bound programatically, the DataContextKeyField field set to the SearchBox will be used as a context field. In order to set ImageUrl for the context items the OnClientItemDataBound event of the Search Context could be used as shown below:

<telerik:RadODataDataSource runat="server" ID="DataSource1">
    <Read Url=""></Read>
    <telerik:DataModel ModelID="Product" Set="Products">
        <telerik:DataModelField FieldName="ProductID" />
        <telerik:DataModelField FieldName="ProductName" />
        <telerik:DataModel ModelID="Supplier" Set="Suppliers">
        <telerik:DataModelField FieldName="SupplierID" />
        <telerik:DataModelField FieldName="ContactName" />
<telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox1"
    DataKeyNames="ProductID, ProductName"
    DataContextKeyField="SupplierID" >
    <DropDownSettings Height="400" Width="300" />
    <SearchContext DataModelID="Supplier" DataKeyField="SupplierID" 
        DataTextField="ContactName"  OnClientItemDataBound="OnClientItemDataBound">
<script type="text/javascript">
    function OnClientItemDataBound(sender, args) {
        var contactName = args.get_dataItem().ContactName;
        args.get_item().set_imageUrl(contactName + "_small.png");
In this article