Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multi column or ItemData in AJAX AutoCompleteExtender?

Posted on 2009-03-31
6
Medium Priority
?
3,425 Views
Last Modified: 2013-11-07
I've got the AJAX AutoCompleteExtender working in my project. For example, one of them a list of suburbs - if you type in "BUR" it will start listing "BURWOOD" "BURWOOD EAST" etc.

That's great, except that to really use the response, I need to access an ID number, not the string itself. For example, the submitted page needs to use Suburb_ID 1500 rather than the string "BURWOOD".

The lazy approach would be to run SQL queries to translate the string back into the ID ("SELECT ID FROM Suburbs WHERE Name = 'BURWOOD'; ") but architecturally and performance wise this is dreadful.

So my question: Is there a way to for AJAX AutoCompleteExtender to store multiple columns, or, associated item data with each item it lists?
0
Comment
Question by:blowfly
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 24048428
I would have to say that I don't remember the AutoCompleteExtender providing that kind of support.
0
 

Author Comment

by:blowfly
ID: 24083931
Fair enough, any ideas on a free/open source alternative which might do this?

Otherwise points to you.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24086287
No, but if you find one, it would be a "treasure"...

I am not saying that one doesn't exist, and that the AutoCompleteExtender doesn't support it.  I am saying that I don't know of any solution...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Closing Comment

by:blowfly
ID: 31565152
Fair enough, thanks for the help.
0
 

Expert Comment

by:avm7878
ID: 24265939
You can accomplish it one of 2 ways. You can create a Custom Control that inherits the AutoCompleteExtender class and override the Render event.

Or... you can go with this guy's javascript solution:
http://www.darwyn.com/blogs/post/2009/03/03/custom-Auto-Complete-Extender-Extended.aspx
0
 

Expert Comment

by:AyhanEren75
ID: 24525232
If I did not misunderstand the need, here is you can try a couple of lines.
 using (SqlConnection ConnStr = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
            {
                ConnStr.Open();
                SqlCommand sqlcmd = new SqlCommand(@"NameOfTheStoredProcedure", ConnStr);
                
	  sqlcmd.CommandType = CommandType.StoredProcedure;                
                sqlcmd.Parameters.Add("@ourComingEnteredWord", SqlDbType.NVarChar, 50).Value = prefixText.Trim().ToLower();
                
                SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
                DataTable dt = new DataTable("ResultTable");
 
                try
                {
                    da.Fill(dt);
                }
                catch {
                
                }
 
                string[] items = new string[dt.Rows.Count];
                int i = 0;
 
                foreach (DataRow dr in dt.Rows)
                {
                    //added for keyvalue pair feature.
                    items.SetValue(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr["SuburbName"].ToString(), dr["SuburbID"].ToString()), i);
                    
                    i++;
                }
 
                
                return items;
 
            }//end of sqlconnection   

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question