MVC 4: How to make DropDownListFor return 0 as optionLabel value?

前端 未结 2 1705
长发绾君心
长发绾君心 2021-01-13 07:09

I have a create view with multiple DropDownListFors. Each time a new object is created only 1 of the DropDownListFors should have a value, I want the others to return 0 as t

2条回答
  •  清酒与你
    2021-01-13 07:33

    Insert a new empty string, here's an example.

    @Html.DropDownListFor(x => x.ProjectID, Model.Projects, string.Empty)
    

提交回复
热议问题