Solved

ASP.net VB.net Add ID value  in addition to Item  DropDownList

Posted on 2016-10-25
2
25 Views
Last Modified: 2016-10-25
Hi

In ASP.net I add text items to a DropDownList. For each of these I also want to store an ID
so that when the user selects the item the app uses the ID and not the text item.

Thanks
0
Comment
Question by:murbro
2 Comments
 
LVL 19

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 41858477
This might not be the most efficient way to do what you're asking about. But, in the past, this is what I've done for something similar.

What I've done is create a Dictionary or Hashtable that contains the ID as the key and the text value for the item as the value. So,

I then store those and at the same time, I add the text string values to the drop down list.

Then, when the DD List item is selected, I ask the Dictionary or Hashtable to give me the key ID for that text value. I now have a way to reverse out the ID from the text.

Otherwise, I'm not sure if this is easily done. You could possibly tie the ID to the index in the DD List, but that might not work if your ID's are like 12098 and your index is 3.

As far as I know though, the items for DD Lists can be objects but are not strongly typed. The only other possible way I can think of doing this would be to subclass the DD List and have the item be a type of Dictionary or such and reverse it though that way once the selection is made.

I
0
 

Author Closing Comment

by:murbro
ID: 41858522
Thanks for the help
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

20 Experts available now in Live!

Get 1:1 Help Now