Avatar of codequest
 asked on

Drop Down List From DataTable - Display One Value, Capture Associated Index

I'd like to have a set-up for a FormView Insert Template Field (call it "ListValue") ( for Table A ) that would act like this:

A)  A drop down list DD is populated from a datatable B (another table)
B)  When an item from the drop down list DD is selected
     i)  the item displayed in the drop down field shows on a field on the Template ("DisplayField")
    ii)  the Primary Key from the datatable B, associated with the drop down list selected item, would be bound to the Table A "List Value" field.

Any suggestions, starting points, etc would be appreciated.


Avatar of undefined
Last Comment

8/22/2022 - Mon

I think I've got the answer.  I'm using TableAdapters.  So I need a Select Query with a Join (or sub-query) that will translate the stored ID value to the Display Value, and Insert/ Update Queries with a sub-query to translate the Display Value back to the ID value.  

This will work because there the Display Values are unique (so no ID confusion in the translation).

The Drop Down is a separate technical matter...it just happens to be the same file.

And then, of course, uh-duh, the Drop Down List control provides for a selected value as well as a display text, so...

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.