Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have textbox and a combobox.i have set an autocomplete for the textbox. the autocomplete loads from a table in database called teacher. the table teacher has 5 columns. i want the textbox to be able to accept multiple autocomplete for the 5 columns so that we i select a column name from the combobox i want the textbox to view the autocomplete for that column name on the combobox pls anybody with an idea
Posted

Write change event for combobox and when change the combobox value


JavaScript
if (jQuery(control).data('autocomplete')) {
  jQuery(control).autocomplete("destroy");
  jQuery(control).removeData('autocomplete');
}

Destroy autocomplte something like above and call ajax according to the combobox value and assign new autocomplete to the TextBox.


Hope this will work
 
Share this answer
 
v2
1.From the user interface you have to send to the logic 2 paramters: the index of selected column (as int), and the string input by the user in the auto-complete textbox.

If your application is a web application the parameters above can be send by using jQuery and AJAX call to the code behind (or controller action), in the case of Windows Forms or WPF application you should controls events for doing this.

2.In the logic you have to use this two parameters and build 5 LINQ (one for each different columns) or a dynamic select query then use it to get the data from the database. Run the current query and returns only the maxim first "n" results like in the example bellow:
C#
var results = query.Take(24).Select(a => new { label = a.Name });
//
return Json(results, JsonRequestBehavior.AllowGet);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900