Create DropDownListFor from SelectList with default value

前端 未结 5 1245
花落未央
花落未央 2021-01-05 08:33

I have a dropdownlistfor:

 @Html.DropDownListFor(model => model.Item.Item.Status, new SelectList(@Model.AllStatus, \"id\", \"Description\"),          


        
5条回答
  •  孤独总比滥情好
    2021-01-05 08:39

    You can use "Insert" for adding default value of Dropdown and add it to your Dynamic list : By this way you don't need to use Razor in your View.

    List m = X.GetList();
    m.Insert(0, new Y{ Name = "--Select--" });
    

提交回复
热议问题