Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. public class PlatInspHistoryModels
  2. {
  3. public List<RadioButtonItem> RadioButtonList { get; set; }
  4. public string SelectedRadioButton { get; set; }
  5. }
  6.  
  7. public class RadioButtonItem
  8. {
  9. public string Name { get; set; }
  10. public bool Selected { get; set; }
  11. public string Value { get; set; }
  12. public bool Visible { get; set; }
  13. }
  14.  
  15. public ActionResult Index()
  16. {
  17. var viewModel = new PlatInspHistoryModels
  18. {
  19. RadioButtonList = new List<RadioButtonItem>
  20. {
  21. new RadioButtonItem
  22. {
  23. Name = "Topside", Value = "T",Selected = true,Visible = true
  24. },
  25. new RadioButtonItem
  26. {
  27. Name="Underwater", Value = "U",Selected = false,Visible = true
  28. }
  29. }
  30. };
  31. return View(viewModel);
  32. }
  33.  
  34. @using (Html.BeginForm("Index", "PlatInspHistory", FormMethod.Post, new { id = "form" }))
  35. {
  36. <table cellpadding="4" cellspacing="4">
  37. <tr>
  38. <td>
  39.  
  40. foreach (Cairs2.Models.RadioButtonItem item in Model.RadioButtonList)
  41. {
  42. @Html.DisplayFor(i => item.Name)
  43. @Html.RadioButton("PlatInspHistoryModels.SelectedRadioButton", item.Value, item.Selected, new { @class = "formCheckbox", tabindex = "1" })
  44. }
  45.  
  46.  
  47. </td>
  48. </tr>
  49. </table>
  50. }
  51.  
  52. [HttpPost]
  53. public ActionResult Index(PlatInspHistoryModels model)
  54. {
  55. }
  56.  
  57. for (var i = 0; i < Model.RadioButtonList.Count; i++)
  58. {
  59. @Html.DisplayFor(x => x.RadioButtonList[i].Name)
  60. @Html.HiddenFor(x => x.RadioButtonList[i].Name)
  61. @Html.RadioButtonFor(x => x.SelectedRadioButton, Model.RadioButtonList[i].Value, new { @class = "formCheckbox", tabindex = "1" })
  62. }
  63.  
  64. @foreach (var item in Model)
  65. {<tr>
  66. <td>
  67. @Html.DisplayFor(modelItem=>item.Qid)</td>
  68. <td> @Html.DisplayFor(modelItem => item.Question)</td> <td>
  69. @Html.RadioButton("skillsq1", new { id = "1"}).
  70. @Html.DisplayFor(modelItem => item.AnsOpt1)</td><td>
  71. @Html.RadioButton("skillsq1", new { id = "2"})
  72. @Html.DisplayFor(modelItem => item.AnsOpt2) </td><td>
  73. @Html.RadioButton("skillsq1", new { id = "3" })
  74. @Html.DisplayFor(modelItem => item.AnsOpt3) </td> <td>
  75.  
  76. @Html.RadioButton("skillsq1", new { id = "4" })
  77. @Html.DisplayFor(modelItem => item.AnsOpt4) </td> </tr>}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement