title: MVC 3 Edit data in a IEnumerable Model View
body: <p>I'm trying to edit a list of items in a strongly-typed razor view. The templates don't give me the option to edit a list of objects in a single view so I merged the List view with the Edit view. I only need to edit one boolean field in a checkbox.
  The problem is that i cant get the data back to the controller. How do i do it? <code>FormCollection</code>? <code>Viewdata</code>? Thanks in advance.</p>
  
  <p>Here's the code:</p>
  
  <p><strong>Models:</strong></p>
  
  <pre><code>public class Permissao
  {
      public int ID { get; set; }
      public TipoPermissao TipoP { get; set; }
      public bool HasPermissao { get; set; }
      public string UtilizadorID { get; set; }
  }
  
  public class TipoPermissao
  {
      public int ID { get; set; }
      public string Nome { get; set; }
      public string Descricao { get; set; }
      public int IndID { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller Actions:</strong></p>
  
  <pre><code>    public ActionResult EditPermissoes(string id)
      {
          return View(db.Permissoes.Include("TipoP").Where(p =&gt; p.UtilizadorID == id));
      }
  
      [HttpPost]
      public ActionResult EditPermissoes(FormCollection collection)
      {
          //TODO: Get data from view
          return RedirectToAction("GerirUtilizadores");
      }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>@model IEnumerable&lt;MIQ.Models.Permissao&gt;
  
  @{
      ViewBag.Title = "EditPermissoes";
  }
  
  @using (Html.BeginForm())
  {
      &lt;table&gt;
  
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;
              Indicador
          &lt;/th&gt;
          &lt;th&gt;
              Nome
          &lt;/th&gt;
          &lt;th&gt;Descrição&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      @foreach (var item in Model) {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.CheckBoxFor(modelItem =&gt; item.HasPermissao)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.TipoP.IndID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.TipoP.Nome)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.TipoP.Descricao)
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  &lt;/table&gt; 
  &lt;p&gt;
     &lt;input type="submit" value="Guardar" /&gt;
   &lt;/p&gt;
  }
  </code></pre>