问题描述
这是我的观点
@using(Html.BeginForm(updateFeedback,调查问卷,FormMethod.Post))
{
for(int i = 0; i< Model.Count(); i ++)
{
Q @ Html.DisplayFor(item => item [i] .QuestionSeq)。 @ Html.DisplayFor(item => item [i] .Question)
var model = Model [i];
if(model.AnsType.Equals(Scale2))
{
< label> @ Html.RadioButton(Question+ model .QuestionSeq,1)好多了< / label>
< label> @ Html.RadioButton(问题+ model.QuestionSeq,2)更好< / label>
< label> @ Html.RadioButton(Question+ model.QuestionSeq,3)关于相同< / label>
< label> @ Html.RadioButton(问题+模型。 QuestionSeq,4)更糟糕< / label>
< label> @ Html.RadioButton(Question+ model.QuestionSeq,5)更糟糕< / label>
}
if(model.AnsType.Equals(Scale6))
{
& lt ; label& gt; @ Html.RadioButton(Question+ model.QuestionSeq,1)非常可能& lt; / label& gt;
& lt; label& gt; @ Html.Radio按钮(问题+ model.QuestionSeq,2)可能& lt; / label& gt;
& lt; label& gt; @ Html.RadioButton(Question+ model.QuestionSeq, 3)Neutral& lt; / label& gt;
& lt; label& gt; @ Html.RadioButton(Question+ model.QuestionSeq,4)不太可能& lt; / label& gt ;
& lt; label& gt; @ Html.RadioButton(Question+ model.QuestionSeq,5)极不可能& lt; / label& gt;
}
}
& lt; input type =submitvalue =Submit/& gt;
}
RadioButton的值在控制器中为空。我理解语法应该是 @ html.RadiobuttonFor 但是我无法在当前上下文中构建它。
帮助将不胜感激。
在此先感谢。
Here is my View
@using (Html.BeginForm("updateFeedback", "Questionnaire", FormMethod.Post))
{
for (int i = 0; i< Model.Count(); i++)
{
Q @Html.DisplayFor(item => item[i].QuestionSeq). @Html.DisplayFor(item => item[i].Question)
var model = Model[i];
if (model.AnsType.Equals("Scale2"))
{
<label>@Html.RadioButton("Question" + model.QuestionSeq, 1)Much Better</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 2)Better</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 3)About the same</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 4)Worse</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 5)Much Worse</label>
}
if (model.AnsType.Equals("Scale6"))
{
<label>@Html.RadioButton("Question" + model.QuestionSeq, 1)Very Likely</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 2)Likely</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 3)Neutral</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 4)Unlikely</label>
<label>@Html.RadioButton("Question" + model.QuestionSeq, 5)Very Unlikely</label>
}
}
<input type="submit" value="Submit" />
}
The values for the RadioButton is coming as null in the controller. I understand the syntax should be @html.RadiobuttonFor but i am unable to frame it in the current context.
Help will be appreciated.
Thanks in advance.
推荐答案
这篇关于如何将Radiobutton的选定值发送到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!