使用逗号保存到数据库的值

时间:2016-02-23 00:57:37

标签: html razor webmatrix

当我运行以下代码时,它总是在末尾用逗号保存TeamIDFirstNameLastName完全保存,但不是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>  

2 个答案:

答案 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)

我是愚蠢的。我在页面上的表单已经有团队更新。通过删除它修复。