嗨,我在由 foreach 循环创建的视图中遇到多个单选按钮的问题都归为一个,因此无论显示多少(通常为 10+),我都只能单击一个,任何帮助都会有所帮助。
看法
@using (Html.BeginForm())
{
foreach (var question in Model.Question)
{
<div id ="quest1">
<div id ="questText">
<div class="cat">
@Html.DisplayFor(model => question.Category.CategoryName)-@Html.DisplayFor(model => question.SubCategory.SubCategoryName)
</div>
<div class="editor-label">
@Html.DisplayFor(model => question.QuestionText)
</div>
<div class="editor-label">
@Html.RadioButtonFor(model => question.QuestionAnsNum,1,new { @sytle = "width:5px;background:none;border:none" })
@Html.DisplayFor(model =>question.A)
</div>
<div class="editor-label">
@Html.RadioButtonFor(model => question.QuestionAnsNum,2,new { @sytle = "width:5px;background:none;border:none" })
@Html.DisplayFor(model =>question.B)
</div>
<div class="editor-label">
@Html.RadioButtonFor(model => question.QuestionAnsNum,3,new { @sytle = "width:5px;background:none;border:none" })
@Html.DisplayFor(model =>question.C)
</div>
<div class="editor-label">
@Html.RadioButtonFor(model => question.QuestionAnsNum,4,new { @sytle = "width:5px;background:none;border:none" })
@Html.DisplayFor(model =>question.D)
</div>
</div>
</div>
<br />
}
<input type="submit" />
}