Solved

Multi column or ItemData in AJAX AutoCompleteExtender?

Posted on 2009-03-31
6
3,365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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