New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Server-side Binding
SearchContext can be easily bound declaratively to some DataSource by setting DatasourceID, DataTextField and DataKeyField properties to the desired fields so that the DataKeyField is the same as the one set to DataContextKeyField of Searchbox control.In server side bindingImageUrl property can be assigned to the SearchContextItem in the ItemDataBound of SearchContext as it is achieved in the code below:
ASPNET
<telerik:RadSearchBox RenderMode="Lightweight" ID="RadSearchBox3" runat="server" Width="500" DataSourceID="SqlDataSource3"
DataTextField="LastName" DataValueField="FirstName" DataContextKeyField="EmployeeID" >
<SearchContext DataSourceID="SqlDataSource3" DataTextField="City" DataKeyField="EmployeeID">
</SearchContext>
</telerik:RadSearchBox>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [LastName], [FirstName], [EmployeeID],[City], [PhotoPath] FROM [Employees]" >
</asp:SqlDataSource>
C#
protected void Page_Load(object sender, EventArgs e)
{
RadSearchBox3.SearchContext.ItemDataBound += SearchContext_ItemDataBound;
}
void SearchContext_ItemDataBound(object sender, SearchBoxContextItemEventArgs e)
{
e.Item.ImageUrl = ((DataRowView)e.Item.DataItem)["PhotoPath"].ToString();
}