title: Post list of list of model object to Controller in ASP.NET MVC
body: <p>Form like this</p>
  
  <p><a href="https://i.stack.imgur.com/VREoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VREoG.png" alt="enter image description here"></a></p>
  
  
  
  <p><strong>ViewModel:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ProductViewModel
  {
      public string Product { get; set; }
      public IEnumerable&lt;SizeColorQuantityViewModel&gt; SizeColorQuantities { get; set; }
  }
  public class SizeColorQuantityViewModel
  {
      public string ColorId { get; set; }
      public List&lt;SizeAndQuantity&gt; SizeAndQuantities { get; set; }
  }
  public class SizeAndQuantity
  {
      public int SizeId { get; set; }
      public int Quantity { get; set; }
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>@model ProjectSem3.Areas.Admin.Models.ProductViewModel
  @{
      ViewBag.Title = "Create";
      Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
      string[] ListColor = { "Red", "Blue" };
      string[] ListSize = { "S", "M", "L", "XL" };
  }
      @for (var i = 0; i &lt; ListColor.Length; i++)
      {
      &lt;div class="form-group"&gt;
         &lt;label class="col-md-2 control-label"&gt;Color:&lt;/label&gt;
         &lt;div class="col-md-2"&gt;
            @Html.TextBox("[" + i + "].ColorId", null, new { @Value = ListColor[i], @class = "form-control", @readonly = "readonly" })
         &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
         &lt;label class="col-md-2 control-label"&gt;Size and Quantity:&lt;/label&gt;
         @for (var j = 0; j &lt; ListSize.Length; j++)
         {
         &lt;div class="col-md-2"&gt;
            @Html.TextBox("[" + i + "][" + j + "].SizeAndQuantities.SizeId", null, new
            {
            @class = "form-control",
            @style = "margin-bottom: 15px",
            @Value = ListSize[j],
            @readonly = "readonly"
            })
            @Html.TextBox("[" + i + "][" + j + "].SizeAndQuantities.Quantity", null, new { @class = "form-control" })
         &lt;/div&gt;
         }
      &lt;/div&gt;
      }
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>// GET: Admin/Product
  public ActionResult Create()
  {
      return View();
  }
  // POST: Admin/Product
  [HttpPost]
  public ActionResult Create(ProductViewModel product, IEnumerable
  &lt;SizeColorQuantityViewModel&gt;
  sizeColorQuantity, IEnumerable
  &lt;SizeAndQuantity&gt;
  sizeAndQuantity)
  { 
       return View();
  }
  </code></pre>
  
  <p>I can get value which is passed from ViewModel <code>IEnumerable&lt;SizeColorQuantityViewModel&gt; sizeColorQuantity</code> to Controller. But with this model <code>IEnumerable&lt;SizeAndQuantity&gt; sizeAndQuantity</code>, I can't get any value.
  Cause this is 2-D Array so, I have no idea for this issues. Could you teach me how to bind value for <code>IEnumerable&lt;SizeAndQuantity&gt; sizeAndQuantity.</code></p>