title: Getting List<ViewModel> from View into Controller
body: <p>I have a <code>View</code> which allows editing a <code>List</code> of <code>ViewModel</code>. The code works till the displaying functionality. But I am unable to get the value in the same list back from the view. </p>
  
  <pre><code>        public ActionResult Funtion()
          {
              List&lt;ViewModel&gt; ViewModel= (List&lt;ViewModel&gt;)TempData["ViewModel"];
              return View(ViewModel);
          }
  
          [HttpPost]
          public ActionResult UserFormSubmission(List&lt;ViewModel&gt; ViewModel)
          {    
              return View();
          }        
  </code></pre>
  
  <p>The value in List of the POST function is null.
  How could i get the values from view into Controller.</p>
  
  <p><strong>EDIT :</strong>
  I tried using the solutions mentioned to assolution to the question <a href="https://stackoverflow.com/questions/17037858/how-to-pass-ienumerable-list-to-controller-in-mvc-including-checkbox-state">How to pass IEnumerable list to controller in MVC including checkbox state?</a>. But encountered the following error:</p>
  
  <blockquote>
    <p>Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable</p>
  </blockquote>
  
  <p>Also i couldnt understand the usage of certain tags in it, like the <code>AntiForgeryToken</code>, <code>HiddenFor</code>, etc. 
  So if possible someone please come up with a Simple solution or a better explanation. </p>
  
  <p><strong>EDIT 2 :</strong> I changed <code>@model IEnumerable&lt;ViewModel&gt;</code> to <code>@model List&lt;ViewModel&gt;</code> and the error Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable has been corrected. </p>
  
  <p><strong>EDIT 3:</strong>
  I was able to get the value of <code>Textbox</code> and <code>CheckBox</code> into the Controller but <code>RadioButton</code> and <code>DropDownList's selected values cant be identified at the</code>[HttpPost]` function? What am I missing here?</p>
  
  <pre><code>@for (i = 0; i &lt; Model.Count(); ++i)
  {
   if (Model[i].TypeId == 4)
                      {
                          //radiobutton
                          for (int j = 0; j &lt; Model[i].Options.Count(); ++j)
                          {
                      &lt;div&gt;
                          @Html.HiddenFor(m =&gt; m[i].Options[j].OptionId)                        
                          @Html.HiddenFor(m =&gt; m[i].Options[j].OptionValue)
                          @Html.HiddenFor(m =&gt; m[i].Options[j].Id)
  
                          @Html.RadioButtonFor(m =&gt; m[i].Options[j].Value, @Model[i].Options[j].DisplayText)
                          @Html.DisplayFor(m =&gt; m[i].Options[j].DisplayText)
                      &lt;/div&gt;
  
                          }
                      }
  }
  </code></pre>