我有以下代码绑定到 @Html.DropDownListFor :
视图模型
public static UserManagementViewModel CreateCompanyMappingViewModel(List<Company> company)
{
UserManagementViewModel viewModel = new UserManagementViewModel();
viewModel.Companies = new SelectList(company, "CompanyID", "CompanyName");
return viewModel;
}
}
cshtml
@Html.DropDownListFor(model => model.CompanyID, Model.Companies, new { style = "width:300px;" })
下拉列表绑定成功。我需要的是,在 DropDownList 中插入一个空白行并首先选择它,同时绑定到 DropDownList。如何 ?