?
Solved

Multi column or ItemData in AJAX AutoCompleteExtender?

Posted on 2009-03-31
6
Medium Priority
?
3,398 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to implement server side field validation and display customized error messages to the client.
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 …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

719 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