title: ASP.NET Bind to IEnumerable
body: <p>I'm passing a the type IEnumerable to my view, and for each item I output a html.textbox to enter the details into.</p>
  
  <p>When I post this back to my controller, the collection is empty and I can't see why.</p>
  
  <pre><code>    public class Item
      {
          public Order Order { get; set; }
          public string Title { get; set; }
          public double Price { get; set; }
      }
  </code></pre>
  
  <p>My Get method:</p>
  
  <pre><code>public ActionResult AddItems(Order order)
      {
          Item itemOne = new Item
          {
              Order = order
          };
  
          Item itemTwo = new Item
          {
              Order = order,
          };
  
          IList&lt;Item&gt; items = new List&lt;Item&gt; { itemOne, itemTwo };
  
          return View(items);
      }
  </code></pre>
  
  <p>The View:</p>
  
  <pre><code>            &lt;% int i = 0; foreach (var item in Model)
             { %&gt;
  
              &lt;p&gt;
                  &lt;label for="Title"&gt;Item Title:&lt;/label&gt;
                  &lt;%= Html.TextBox("items[" + i + "].Title") %&gt;
                  &lt;%= Html.ValidationMessage("items[" + i + "].Title", "*")%&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  &lt;label for="Price"&gt;Item Price:&lt;/label&gt;
                  &lt;%= Html.TextBox("items[" + i + "].Price") %&gt;
                  &lt;%= Html.ValidationMessage("items[" + i + "].Price", "*")%&gt;
              &lt;/p&gt;
  
          &lt;% i++;
             } %&gt;
  </code></pre>
  
  <p>The POST method:</p>
  
  <pre><code> [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult AddItems(IEnumerable&lt;Item&gt; items)
      {
          try
          {
  
              return RedirectToAction("Index");
          }
          catch
          {
              return View();
          }
      }
  </code></pre>
  
  <p>At the moment i just have a breakpoint on the post method to check what i'm gettin back.  </p>