title: Model value is getting null when form post
body: <p>I populate my model and pass that model to view from action method. with for loop in view I generate radio button based on model.</p>
  
  <p>just see this code. here I populate my model manually and pass to view from action method.</p>
  
  <pre><code>[HttpGet]
          public ActionResult Index()
          {
              ViewBag.Message = "Welcome to ASP.NET MVC!";
              var student = new StudentModel
              {
                  FirstName = "Rion",
                  LastName = "Gomes",
  
                  //I think the best way to populate this list is to call a service here.
                  Sex = new List&lt;Sex&gt;
                  {
                      new Sex{ID="1" , Type = "Male"},
                      new Sex{ID="2" , Type = "Female"}
                  }
              };
  
              return View(student);
          }
  </code></pre>
  
  <p>based on Sex property I generate no of radio button in loop and when I select any radio button and click on form submit then form data properly deserialize to my model in action method but when I am checking the sex property then I saw it is showing null value. I am new in mvc and not being able to understand why my sex property is getting null when form submit to action.</p>
  
  <p>here is my full code and please tell me where I am making mistake. thanks</p>
  
  <h2>controller code</h2>
  
  <pre><code>public class HomeController : Controller
      {
          [HttpGet]
          public ActionResult Index()
          {
              ViewBag.Message = "Welcome to ASP.NET MVC!";
              var student = new StudentModel
              {
                  FirstName = "Rion",
                  LastName = "Gomes",
  
                  //I think the best way to populate this list is to call a service here.
                  Sex = new List&lt;Sex&gt;
                  {
                      new Sex{ID="1" , Type = "Male"},
                      new Sex{ID="2" , Type = "Female"}
                  }
              };
  
              return View(student);
          }
  
          [HttpPost]
          public ActionResult Index(StudentModel model)
          {
              if (ModelState.IsValid)
              {
                  //TODO: Save your model and redirect
              }
  
              //Call the same service to initialize your model again (cause we didn't post the list of sexs)
              return View(model);
          }
          public ActionResult About()
          {
              return View();
          }
      }
  </code></pre>
  
  <h2>model code</h2>
  
  <pre><code>public class StudentModel
      {
          [Required(ErrorMessage = "First Name Required")] // textboxes will show
          [Display(Name = "First Name :")]
          [StringLength(5, ErrorMessage = "First Name cannot be longer than 5 characters.")]
          public string FirstName { get; set; }
  
          [Required(ErrorMessage = "Last Name Required")] // textboxes will show
          [Display(Name = "Last Name :")]
          [StringLength(5, ErrorMessage = "Last Name cannot be longer than 5 characters.")]
          public string LastName { get; set; }
  
  
          public List&lt;Sex&gt; Sex { get; set; }
        }
  
      public class Sex
      {
          public string ID { get; set; }
          public string Type { get; set; }
      }
  </code></pre>
  
  <h2>here is my view code.</h2>
  
  <pre><code>@model MvcRadioButton.Models.StudentModel
  @{
      ViewBag.Title = "Home Page";
  }
  @using(Html.BeginForm())
  {
      &lt;div&gt;
          @Html.LabelFor(model =&gt; model.FirstName)
          @Html.EditorFor(model =&gt; model.FirstName)
          @Html.ValidationMessageFor(model =&gt; model.FirstName)
      &lt;/div&gt;
      &lt;div&gt;
          @Html.LabelFor(model =&gt; model.LastName)
          @Html.EditorFor(model =&gt; model.LastName)
          @Html.ValidationMessageFor(model =&gt; model.LastName)
      &lt;/div&gt;
  
      foreach (var Sex in Model.Sex)
      {
              &lt;div&gt;
                  @Html.RadioButtonFor(model =&gt; model.Sex, Sex.ID, new { @id = ("sex" + Sex.ID) })
                  @*@Html.Label("Sex", sex.Type)*@
                  @Html.Label("sex" + Sex.ID, Sex.Type)
              &lt;/div&gt;
      }
     &lt;input type="submit" value="Submit" /&gt;
  }
  </code></pre>
  
  <p>also guide me how could I set validation on my sex property. if anyone try to submit form without selecting any radio button then a message will display. thanks please guide that where I am making mistake.</p>