当我运行以下代码时,它总是在末尾用逗号保存TeamID
。 FirstName
和LastName
完全保存,但不是TeamID
。
<div class="form-group">
<select class="form-control" name="" >
<div>@foreach(var Team in MyTeam){
<option value="">@Team.FirstName @Team.LastName</option>
<input type="hidden" name="FirstName" value=@Team.FirstName>
<input type="hidden" name="LastName" value=@Team.LastName>
<input type="hidden" name="TeamID" value=@Team.UserID>
}
</select>
</div>
答案 0 :(得分:0)
我意识到“div”在错误的地方。问题已解决 - 感谢@Steve帮助我看到:
<select class="form-control" name="">
<div>@foreach(var Team in MyTeam){
<option value="">@Team.FirstName @Team.LastName</option>
<input type="hidden" name="FirstName" value=@Team.FirstName>
<input type="hidden" name="LastName" value=@Team.LastName>
<input type="hidden" name="TeamID" value=@Team.UserID>
}
</div>
</select>
答案 1 :(得分:0)