To do this, you need to return the list from the web service method with identifier and text
Here "lst" is the actual list with data from your data source.
List<string> items = new List<string>(count); for (int i = 0; i < lst.Count; i++) { string str =AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(lst[i].Text,Convert.ToString(lst[i].IDValue)); items.Add(str); } return items.ToArray();
Then simple javascript
function GetID(source, eventArgs ) { var HdnKey = eventArgs.get_value(); document.getElementById('<%=hdnID.ClientID %>').value = HdnKey; }
and don't forget to set the attribute in autocomplete OnClientItemSelected = "GetID"
source share