多个单选按钮asp.net

时间:2013-11-04 14:36:09

标签: asp.net-mvc radio-button html-helper

嗨我在foreach循环创建的视图中遇到多个单选按钮的问题都被分组为一个,所以我只能点击一个,无论显示多少(通常是10+),任何帮助都会有所帮助。 / p>

查看

     @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" />
}

1 个答案:

答案 0 :(得分:0)

为每个组中的所有元素设置相同的名称属性 另外,修复“sytle”字:)