3
我使用foreach循环insoide我的视图中显示几行单选按钮..可能更改RadioButtonFor的名称?
sample radiobutton
<tr>
<td width="30%">
Integrity
</td>
<td width="17%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 1, new { id = "main_" + i + "__nested_integrity) Poor
</td>
<td width="18%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 2, new { id = "main_" + i + "__nested_integrity" }) Satisfactory
</td>
<td width="18%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 3, new { id = "main_" + i + "__nested_integrity" }) Outstanding
</td>
<td width="16%">@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 4, new { id = "main_" + i + "__nested_integrity" }) Off
</td>
</tr>
,因为我得到的问题,同时示范因此结合我创建指南ID,以满足我的需求(不同的递增ID)。
但我想问题来自名称属性。 为第一个和每个循环我得到相同的名称属性(不递增),即如果我从第一个循环选择radiobuttton,然后取消选择其他循环的行。
像
Loop1 id= "main_0__nested_integrity"
Loop2 id= "main_0__nested_integrity"
Loop1 name= "nested.integrity"
Loop2 name= "nested.integrity"
,你可以看到name属性所有环路都一样,用不同的ID。
现在我的问题是...重写RadioButtonFor的名称属性如ID是否可行?
是疗法任何替代? – RollerCosta
是的,使用编辑器模板。我已经更新了我的答案以示例。 –
这是为我创建编辑器,但我需要radiobuttons – RollerCosta