How to set the value for dropdownlist of AJAX autocomplete control?
-
Hi, I am using Microsoft AJAX autocomplete to lookup some product from database. I am wondering if it's possible to access onSelected event of the dropdownlist. Actually, what I want to do is only display product name in dropdownlist, and keep product ID in value field of the dropdownlist. When a user select an item from the dropdownlist, I will retrieve the product ID from the dropdown control for futher action. But since the webservice only return one string and that string is populated into dropdownlist automatically. I couldn't find how to set the text and value for dropdownlist using diffrerent values.... Did anyone have idea how to achieve it? Any help would be really appreciated! Thanks!
-
Hi, I am using Microsoft AJAX autocomplete to lookup some product from database. I am wondering if it's possible to access onSelected event of the dropdownlist. Actually, what I want to do is only display product name in dropdownlist, and keep product ID in value field of the dropdownlist. When a user select an item from the dropdownlist, I will retrieve the product ID from the dropdown control for futher action. But since the webservice only return one string and that string is populated into dropdownlist automatically. I couldn't find how to set the text and value for dropdownlist using diffrerent values.... Did anyone have idea how to achieve it? Any help would be really appreciated! Thanks!
Hi, The AutoCompleteExtender control was not really designed to be used with a DropDownList, as it can only return a string array to the client. If using a TextBox, as oppossed to a DropDownList, is not a viable option for you then you may need to look at writing a custom control that extends the functionality of the AutoCompleteExtender to return name/value pairs.
Clean code is the key to happiness.