我使用剃刀语法,如果未选择下拉菜单或下拉文本为“选择一个”,我想将值设置为= 0 而且我有多个下拉菜单。并且我通过表单集合获取了此值
@Html.DropDownListFor(model => item.JobStaffId, (SelectList)newSelectStaffList,new { @class = "form-control js-select js-noFilter hidden DDStaff DD2 ",multiple="multiple", size = "2", Id = "JobStaffId" + t })
SelectList newSelectList = new SelectList((from s in Model.UserMasterList
.ToList()
select new
{
userId = s.userId,
userName = (s.userFirstName +' '+ s.userLastName)
}).Distinct()
,
"userId",
"userName",
string.IsNullOrEmpty(item.JobConstructionManagerId.ToString()) ? 0 : item.JobConstructionManagerId);
答案 0 :(得分:1)
您可以执行以下操作:
<form action="..." method="post">...</form>