title: post items of webgrid asp.net mvc3
body: <p>I have these DTO's</p>
  
  <pre><code>public class Header
  {
      public int HeaderId{get;set;}
      public int Description{get;set;}
      public List&lt;HeaderItem&gt; HeaderItems{get;set;}
  
  }
  
  public class HeaderItem
  {
      public int HeaderItemId{get;set;}
      public string DetailDescription{ get; set; }
      public bool Selected{ get; set; }
  }
  </code></pre>
  
  <p>and I have this Controller</p>
  
  <pre><code>    [HttpPost]
      public ActionResult PostMethod(Header dto)
      {
          ...
      }
  </code></pre>
  
  <p>and this html</p>
  
  <pre><code>  @using (Html.BeginForm("PostMethod", "Controller", FormMethod.Post, new { id = "form" }))
  
  {
  
  @Html.TextBoxFor(x =&gt; x.Description)    
  
  var grid = new WebGrid(Model.HeaderItems);
      }
      @grid.GetHtml(tableStyle: "grid",
      htmlAttributes: new { id = "grid" },
      columns: grid.Columns(
      grid.Column("Selected", "Seç", format: (item) =&gt; Html.CheckBox(String.Format("Selected_{0}", (int)item.HeaderItemId), false)),
      grid.Column("HeaderItemId", "", format: (item) =&gt; Html.Hidden("HeaderItemId")),
      grid.Column("DetailDescription", "Description")
      )
  </code></pre>
  
  <p>
  }</p>
  
  <p>So, this grid have a checkbox and a HiddenField that hold the HeaderItemId value of each row.</p>
  
  <p>I would like to post my form and have my property HeaderItems of Header class filled.</p>
  
  <p>How could I reach this solution?</p>