Generieren einer MVC3-RadioButton-Liste in einer Schleifenanweisung

Eine meiner Kollegien hat ein Modell geschaffen und hier ist es.

Modell

[Serializable]
public class ModifyCollegeListModel
{
    public List<SchoolModel> CollegeList { get; set; }
    public List<SchoolListModel> SchoolList { get; set; }
    public string Notes { get; set; }
    public int QuestionnaireId { get; set; }
}

[Serializable]
public class SchoolModel
{
    public Guid SchoolId { get; set; }
    public string SchoolName { get; set; }
    public string StateName { get; set; }
    public int DisplayIndex { get; set; }
    public int DetailId { get; set; }
    public int CategoryId { get; set; }
    public int? ApplicationStatusId { get; set; }
}

Ich beabsichtige, eine Schleife zu erstellen, die die Radiobutton-Liste für die ApplicationStatusId generiert, etwa so ...

Rasiermesser-Code

   @foreach (SchoolModel justright in Model.CollegeList.Where(m => m.CategoryId == 3).OrderBy(m => m.SchoolName).ToList<SchoolModel>())
    {
        <tr class="@HtmlHelpers.WriteIf(eventCounter % 2 == 0, "even", "odd")">
                <td class="school"><b>@justright.SchoolName</b></td>
                <td class="location"><b>@justright.StateName</b></td>
            <td><label>@Html.RadioButtonFor(x => justright.SchoolId, (int)BrightHorizons.CC.BusinessLogic.CollegeListApplicationStatusEnum.DidNotApply)</label></td>
            <td><label>@Html.RadioButtonFor(x => justright.SchoolId, (int)BrightHorizons.CC.BusinessLogic.CollegeListApplicationStatusEnum.Accepted)</label></td>
            <td><label>@Html.RadioButtonFor(x => justright.SchoolId, (int)BrightHorizons.CC.BusinessLogic.CollegeListApplicationStatusEnum.NotAccepted)</label></td>
        </tr>

    }

Es kommt jedoch vor, dass ALLE erstellten Radiobuttons denselben Namen haben, sodass sie zu einer riesigen Radiobuttonsammlung zusammengefasst werden. nicht über die schoolID ...Kratzer am Kopf

Kann mir hier jemand helfen und mich in die richtige Richtung weisen, wie ich Optionsfelder erstellen kann, die pro Zeile gruppiert sind?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage