MVC - Set selected value of SelectList

后端 未结 14 1168
后悔当初
后悔当初 2020-12-13 08:03

How can I set the selectedvalue property of a SelectList after it was instantiated without a selectedvalue;

SelectList selectList = new SelectList(items, \"I         


        
14条回答
  •  [愿得一人]
    2020-12-13 09:03

    I ended up here because SelectListItem is no longer picking the selected value correctly. To fix it, I changed the usage of EditorFor for a "manual" approach:

            
    

    Hope it helps someone.

提交回复
热议问题