Solved

Multi column or ItemData in AJAX AutoCompleteExtender?

Posted on 2009-03-31
6
3,317 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 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now