ASP.NET AJAX AutoCompleteExtender - Text/Value Pairs

I've got the AJAX AutoCompleteExtender working on my page, however when the user selects a customer name from the list I need the textbox to pass the customer ID value and not the name?

Is there a way to do this?  

My code is attached.  The CUSTOMID is the ID and the SOLDTO is the Customer name that appears in the list.
codesnippet.txt
cdemott33Asked:
Who is Participating?
 
meetingexpectationsCommented:
You can save the result into a datatable and either cache it or store it in session. Then on "txtCustomerSearch" textbox changed event Filter the datatable according to your selection to get the customid. If you need example, please let me know.
0
 
masterpassCommented:
you can make use of the contextkey that is available .... But you can't use it with the textbox .. To use that you might need a dropdownlist

http://www.aspdotnetcodes.com/AutoComplete_Textbox_Addtional_Parameters.aspx
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
masterpassCommented:
A small typo .. You can use  with the textBox but will an additional dropdownlist

http://www.aspdotnetcodes.com/AutoComplete_Textbox_Addtional_Parameters.aspx
0
 
cdemott33Author Commented:
I think you may not have understood what I'm attempting to do.  I need to the user type in a customer name and then, when the user hits submit, the customer ID is passed?  Make sense?

My db is something like this

ID  |  Customer Name
1   |  Walbaums
2   |  Walmart
3   |  Walnut Shoping Center

Basically, if the user enter "Wal" in the textbox and selects "Walmart" from the list I want to pass the Walmart ID (in this case the number 2) and not the name.  
0
 
masterpassCommented:
Yes, you can very well do that. For that you have implement CreateAutoCompleteItem

When you are adding the data to be returned, use CreateAutoCompleteItem
While sdr.Read
    customers.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(sdr("SOLDTO").ToString(), sdr("CUSTOMID").ToString()))
End While

Open in new window

0
 
cdemott33Author Commented:
Thanks masterpass.  I've added the code to my page but I'm still not sure how, after the user selects a value from the list, do I get the CUSTOMID rather than the SOLDTO value?  Can you give me a bit more detail on how I accomplish this?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.