English 中文(简体)
ASP. NET MVC2: 如何在电网中使用无线电布道?
原标题:ASP.NET MVC2 : How to use radiobuttons in a grid?

还有一个有关Buttons电台/ButtonList电台的问题。

一、导 言

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>
    <% } %>

一、导 言

<% for (int i = 0; i <= 5; i++) { %>
    <td align="center">
        <%= Html.RadioButton("SelectedLevel", i, new { id = Model.Id + "_" + i })%>
    </td>
<% } %>

问题是,尽管有一定水平的无线电台,但并未检查任何无线电台。

这里有什么错误?

问题回答

部分意见中的法典应当包括:

<%= Html.RadioButton("SelectedLevel_" + Model.Id, i, Model.SelectedLevel == i) %>

您必须说明是否选择了电台:

Html.RadioButton("SelectedLevel", i, i == (Model.SelectedLevel ?? -1), new { id = Model.Id + "_" + i })




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!