Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlatInspHistoryModels
- {
- public List<RadioButtonItem> RadioButtonList { get; set; }
- public string SelectedRadioButton { get; set; }
- }
- public class RadioButtonItem
- {
- public string Name { get; set; }
- public bool Selected { get; set; }
- public string Value { get; set; }
- public bool Visible { get; set; }
- }
- public ActionResult Index()
- {
- var viewModel = new PlatInspHistoryModels
- {
- RadioButtonList = new List<RadioButtonItem>
- {
- new RadioButtonItem
- {
- Name = "Topside", Value = "T",Selected = true,Visible = true
- },
- new RadioButtonItem
- {
- Name="Underwater", Value = "U",Selected = false,Visible = true
- }
- }
- };
- return View(viewModel);
- }
- @using (Html.BeginForm("Index", "PlatInspHistory", FormMethod.Post, new { id = "form" }))
- {
- <table cellpadding="4" cellspacing="4">
- <tr>
- <td>
- foreach (Cairs2.Models.RadioButtonItem item in Model.RadioButtonList)
- {
- @Html.DisplayFor(i => item.Name)
- @Html.RadioButton("PlatInspHistoryModels.SelectedRadioButton", item.Value, item.Selected, new { @class = "formCheckbox", tabindex = "1" })
- }
- </td>
- </tr>
- </table>
- }
- [HttpPost]
- public ActionResult Index(PlatInspHistoryModels model)
- {
- }
- for (var i = 0; i < Model.RadioButtonList.Count; i++)
- {
- @Html.DisplayFor(x => x.RadioButtonList[i].Name)
- @Html.HiddenFor(x => x.RadioButtonList[i].Name)
- @Html.RadioButtonFor(x => x.SelectedRadioButton, Model.RadioButtonList[i].Value, new { @class = "formCheckbox", tabindex = "1" })
- }
- @foreach (var item in Model)
- {<tr>
- <td>
- @Html.DisplayFor(modelItem=>item.Qid)</td>
- <td> @Html.DisplayFor(modelItem => item.Question)</td> <td>
- @Html.RadioButton("skillsq1", new { id = "1"}).
- @Html.DisplayFor(modelItem => item.AnsOpt1)</td><td>
- @Html.RadioButton("skillsq1", new { id = "2"})
- @Html.DisplayFor(modelItem => item.AnsOpt2) </td><td>
- @Html.RadioButton("skillsq1", new { id = "3" })
- @Html.DisplayFor(modelItem => item.AnsOpt3) </td> <td>
- @Html.RadioButton("skillsq1", new { id = "4" })
- @Html.DisplayFor(modelItem => item.AnsOpt4) </td> </tr>}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement