Edit this page


DataKeyNames property lists the additional fields of the DataSource that will be mapped to each result item. They can be easily retrieved and used after that in the OnClientSearch event and in the OnSearch server event, as show in the following code:

<script type="text/javascript">
    function OnClientSearch(sender, args) {
  <telerik:RadTextBox RenderMode="Lightweight" runat="server" ID="RadTextBox1">
<telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox1" OnClientSearch="OnClientSearch" OnSearch="RadSearchBox1_Search" 
    DataKeyNames="UnitPrice, SupplierID"
    DataValueField="ProductId"  MaxResultCount="10"
    <DropDownSettings Height="400" Width="300">


<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
    SelectCommand="SELECT * FROM [Products]">

protected void RadSearchBox1_Search(object sender, Telerik.Web.UI.SearchBoxEventArgs e)
    string ProductId = ((Dictionary<string, object>)e.DataItem)["UnitPrice"].ToString();
    string ProductName = ((Dictionary<string, object>)e.DataItem)["SupplierID"].ToString();
    RadTextBox1.Text = ProductId + " " + ProductName;

Protected Sub RadSearchBox1_Search(sender As Object, e As Telerik.Web.UI.SearchBoxEventArgs)
    Dim ProductId As String = DirectCast(e.DataItem, Dictionary(Of String, Object))("UnitPrice").ToString()
    Dim ProductName As String = DirectCast(e.DataItem, Dictionary(Of String, Object))("SupplierID").ToString()
    RadTextBox1.Text = ProductId + " " + ProductName
End Sub

Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article