Get return value ID of Autocomplete Box

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 22 Jan 2014 Link to this post

    I have a web service that I want to return 2 values   and ID and a text value hrough and autocompletebox.  I have it working to return the service but now I need to get at the ID value that was returned, not the text value.  I would like to be able to do an Autopostback on the autocompletebox and hit a database with the ID to return more data to the page.  Is this possible iwht the autocompletebox as I have not been able to find code that shows this.  It would be similar to the asp Autocomplete extender that can return 2 values that you can then use.  Can I do this with a telerik AutocompleteBox.

    <telerik:radautocompletebox ID="rdSearch" runat="server" EmptyMessage="Type Last Name First Name" EnableAutoComplete="true" MinFilterLength="2" MaxResultCount="20" Width="260px"
                                       DropDownHeight="100px" DropDownWidth="250px" DropDownPosition="static" AutoPostBack="true" OnClientEntryAdded="requesting">
                                        <TextSettings SelectionMode="Single" />
                                        <WebServiceSettings Path="../AutoComplete.asmx" Method="GetNames" />
      function requesting(sender, eventArgs) {
                var context = eventArgs.get_context();
                //Data passed to the service.
               // context["ClientData"] = "ClientData_Passed_To_The_Service";
        public AutoCompleteBoxData GetNames(RadAutoCompleteContext context)
            string sql = "select intPersonnelId, strFullname FullName FROM tblMNNatPersonnel WHERE strFullname like '" + context.Text + "%'";
            //SqlDataAdapter adapter = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
            DataTable myDataTable = new DataTable();
            myDataTable = c.GetReader(sql);
            List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
            AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
            result = new List<AutoCompleteBoxItemData>();
            for (int i = 0; i < myDataTable.Rows.Count; i++)
                AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
                itemData.Text = myDataTable.Rows[i]["FullName"].ToString();
                itemData.Value = myDataTable.Rows[i]["intPersonnelId"].ToString();
            dropDownData.Items = result.ToArray();
            return dropDownData;
    When it returns to the autocomplete box I need to do take the intPersonnelId and hit a database and return more information.

  2. Kate
    Kate avatar
    1898 posts

    Posted 27 Jan 2014 Link to this post

    Hi Kevin,

    Please take a look at the following help article related to the Binding of the RadAsutoCompleteBox to Web service. Is this the desired functionality that you need to achieve? As a side note I would like to ask you if you tried using the OData Binding that is already described here? Is this helpful in your scenario?

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top