title: MVC 4 Model Binding to Radio button list on Submit
body: <p>My project is MVC 4 with jquery mobile. I'm trying to figure out how to fill my model with data on submit with the following:</p>
  
  <ol>
  <li><p>From a hidden value that will be populated on the get request</p></li>
  <li><p>Checked Radio button value from a list on the view</p></li>
  </ol>
  
  <p>Here is my Model:</p>
  
  <pre><code> public class ResultsModel
  {
  
      [Display(Name = "PatientFirstName")]
      public string PatientFirstName { get; set; }
  
      [Display(Name = "PatientLastName")]
      public string PatientLastName { get; set; }
  
      [Display(Name = "PatientMI")]
      public string PatientMI { get; set; }
  
      public List&lt;QuestionModel&gt; QuestionList = new List&lt;QuestionModel&gt;();
  
  }
  
  public class QuestionModel
  {
      public string Question { get; set; }
      public int QuestionID { get; set; }
      public int AnswerID { get; set; }
  }
  </code></pre>
  
  <p>It has a collection of questions that is filled with data on the get request.  Here is the controller code:</p>
  
  <pre><code> public class ResultsController : Controller
  {
      //
      // GET: /Results/
  
      public ActionResult Index()
  {
  
      if (Request.IsAuthenticated)
      {
              ResultsModel  resultsModel = new ResultsModel();
  
              //Get data from webservice
              myWebService.TestForm  inrform;
              var service = new myWebService.myService();
              testform = service.TestForm(id);
  
              if (testform != null)
              {
                  //Render the data into results data model
                  int count = 1;
                  string text = string.Empty;
                  foreach (myWebService.Question questiontext in testform.QuestionList)
                  {
                      QuestionModel newquestion = new QuestionModel();
                      text = "Question "  + count + ": " + questiontext.text;
                      if (questiontext.text != null)
                      {
                          newquestion.Question = text;
                          newquestion.QuestionID = questiontext.id;
                      }
                      resultsModel.QuestionList.Add(newquestion);
  
                      count += 1;
                  }                     
  
              }
              else
              {
                  //Error
              }
  
  
              return View(resultsModel);
          }
  
  
          // Error
          return View();
  
  }
  
  [AllowAnonymous]
  [HttpPost]
  public ActionResult Index(ResultsModel model,FormCollection fc)
  {
      if (fc["Cancel"] != null)
      {
          return RedirectToAction("Index", "Home");
      }
      if (ModelState.IsValid)
      {
  </code></pre>
  
  <p>in the post action, the model.QuestionList is always empty.  Here is my View:</p>
  
  <pre><code>    @model Models.ResultsModel 
  
  
  @{
      ViewBag.Title = Resources.Account.Results.Title;
  }
  
  
  @using (Html.BeginForm())
  {
      @Html.ValidationSummary(true)
  
          &lt;li data-role="fieldcontain"&gt;
              @Html.LabelFor(m =&gt; m.INRTestDate)
              @Html.EditorFor(m =&gt; m.INRTestDate)
              @Html.ValidationMessageFor(model =&gt; model.INRTestDate)
  
          &lt;/li&gt;
  
          &lt;li data-role="fieldcontain"&gt;
              @Html.LabelFor(m =&gt; m.INRValue)
              @Html.TextBoxFor(m =&gt; m.INRValue)            
          &lt;/li&gt;
  
      &lt;li&gt;
  
      @for (int i = 0; i &lt; Model.QuestionList.Count; i++)
      {
                      &lt;div data-role="label" name="question" &gt;
                  @Model.QuestionList[i].Question&lt;/div&gt;  
          @Html.HiddenFor(m =&gt; m.QuestionList[i].QuestionID)
  
       &lt;div data-role="fieldcontain"&gt;
           &lt;fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain" &gt;
               &lt;input id="capture_type_yes" name="answer_type" type="radio" data-theme="c" value="1" /&gt;
               &lt;label for="capture_type_yes" &gt;
                   Yes&lt;/label&gt;
               &lt;input id="capture_type_no" name="answer_type" type="radio" data-theme="c" value="0" /&gt;
               &lt;label for="capture_type_no"&gt;
                   No&lt;/label&gt;
               &lt;input id="capture_type_na" name="answer_type" type="radio" data-theme="c" value="2" /&gt;
               &lt;label for="capture_type_na"&gt;
                   Not Applicable&lt;/label&gt;
           &lt;/fieldset&gt;
          &lt;/div&gt; } 
          &lt;label for="textarea-a"&gt;
              Comments&lt;/label&gt;
          &lt;textarea name="textarea" id="textarea-a"&gt; &lt;/textarea&gt;
          &lt;fieldset class="ui-grid-a"&gt;
              &lt;div class="ui-block-a"&gt;
                  &lt;button type="submit" name="Submit" data-theme="c"&gt;Submit&lt;/button&gt;&lt;/div&gt;
              &lt;div class="ui-block-b"&gt;
                  &lt;button type="submit" name="Cancel" data-theme="b" class="cancel"&gt;Cancel&lt;/button&gt;&lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/li&gt;
  </code></pre>
  
  <p>In the for each code above, my model.Questionlist collection is not being updated.  I also need to figure out how I can tie the radio button click (Yes,No or Not Applicable) to the AnswerID property of my model.Questionlist collection</p>