0
又一個關於單選按鈕的問題/ RadioButtonList的ASP.NET MVC2:如何在網格中使用單選按鈕?
我下面型號:
public class SkillLevelModel
{
public long? Id { get; set; }
public int? SelectedLevel { get; set;}
}
我下面控制器:
public class SkillController : BaseController
{
public ActionResult Index()
{
var skills = new List<SkillLevelModel>();
for (int i = 0; i < 10; i++)
skills.Add(new SkillLevelModel() { Id = i, SelectedLevel = new Random().Next(0,5) });
return View(skills);
}
我下面代碼在查看:
<% foreach (var item in Model) { %>
<tr>
<td style="width: 30px" align="center">
<%= Html.Encode(item.Id) %>
</td>
<td>
<% Html.RenderPartial("UCSkillLevel", item); %>
</td>
</tr>
<% } %>
我已經在PartialView下面的代碼:
<% for (int i = 0; i <= 5; i++) { %>
<td align="center">
<%= Html.RadioButton("SelectedLevel", i, new { id = Model.Id + "_" + i })%>
</td>
<% } %>
的問題是,沒有單選按鈕被選中,althought他們有一個水平。
這裏有什麼問題?