ASP.net MVC how to get the value of the ID field for the list of items? [duplicate]
I have an application, that shows list of items bound to a typed model.
In the list every item has an ID from a lookup table.
How to show the value of the lookup data for each item instead of IDs?
The best way has to link a html dropdownlist to each ID, from where I would be able to choose the appropriate value.
Thanks in advance
Gabr开发者_运维问答ile
Well the first step is to make sure you get all of the values that will be in the DropDownList. You should be able to easily fetch this from your database.
Set the text of the DropDownList items to the text value for the lookup item, and set the value to the ID of those same items.
When creating the DropDownList make sure to set the Selected one to be the option which matches the ID of your modeled data item.
精彩评论