I m trying to get a list of radiobuttons from the controller and display it on the View but it dosent seem to be working. I have the following model
public class Module
{
public int ModuleId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
}
In the controller I am getting the list of modules and passing it to the view:
[HttpGet]
public ActionResult SelectAdmin()
{
//getting the list of modules from db
List<Module> modulelst = GetModules();
ViewBag.lstm = modulelst;
return PartialView();
}
Now in the View I'm trying to display the list of modules in the form of RadioButtons/Checkboxes and getting the corresponding id for the module which is selected.
The code for the View I am trying is as follows:
@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>
}
The Above View is not getting displayed
Can anyone please suggest me a solution ?