Get the text from Html.DropdownListFor…MVC3

前端 未结 4 741
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 18:57

I have a model:

public class DocumentModel
{
    public int TypeID { get; set; }
    public List DocumentTypes { get; set; }
}
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 19:34

    On your model I would have another string -

    public string Selected{ get; set; }
    

    then in your view :

    @Html.DropDownListFor(model => model.Selected, new SelectList(Model.DocumentTypes, "Value", "Text"))
    

提交回复
热议问题