我正在尝试从控制器获取单选按钮列表并将其显示在视图上,但它似乎正在工作。我有以下型号
public class Module
{
public int ModuleId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
}
在控制器中,我获取模块列表并将其传递给视图:
[HttpGet]
public ActionResult SelectAdmin()
{
//getting the list of modules from db
List<Module> modulelst = GetModules();
ViewBag.lstm = modulelst;
return PartialView();
}
现在在视图中,我试图以 RadioButtons/Checkboxes 的形式显示模块列表,并获取所选模块的相应 ID。
我正在尝试的视图代码如下:
@model List<MyFriday.Domain.Model.Client>
@using (Ajax.BeginForm("SelectAdmin", "CMAdmin", null, new AjaxOptions { UpdateTargetId = "update-message", InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess = "UpdateSuccess" }, new { @ id = "EditForm" })) { @Html.ValidationSummary(true)
<fieldset>
<div class="content">
@using (Html.BeginForm())
{
<div>
Select the Admin Type:
</div>
<div id="divModules">
@foreach (var Modules in ViewBag.lstm)
{
<div class="formlabel">
<div align="right" class="label" style="cursor: pointer; position: relative;">
@(Modules.First().Title)
</div>
</div>
<div class="formelement">
<input type="radio" id=""/>
@(Modules.First().ModuleId)
</div>
<div style="clear: both;">
</div>
}
</div>
<input id="Submit1" type="submit" value="Submit"/>
<input type="button" value="Cancel" onclick="javascript:cancelconfirm(this)"/>
}
<div style="clear: both;">
</div>
</div>
</fieldset>
}
上面的视图没有显示
谁能给我一个解决方案?