Bind Html.DropDownList with static items
问题 I have to bind an Html.DropDownList with just two items statically. Text="Yes" Value="1" Text="No" Value="0" The important thing is that, I have to set the text and value fields. How can I do this? 回答1: It is a best practice not to create the SelectList in the view. You should create it in the controller and pass it using the ViewData. Example: var list = new SelectList(new [] { new { ID = "1", Name = "name1" }, new { ID = "2", Name = "name2" }, new { ID = "3", Name = "name3" }, }, "ID",