title: Enumerating posted data in form order in ASP.NET MVC
body: <p>Order entry form from Windows CE 6 contains fields with duplicate column names. 
  This data needs to be enumerated in ASP.NET MVC4 application in post controller.</p>
  
  <p>Column names are not known in the controller, since the form is created at runtime from user-defined data.</p>
  
  <p>I tried code below, but it returns comma separated values for duplicate names.</p>
  
  <p>How to get every posted key/value pair separately in the order which they appear in the form?
  Data can also be posted in json format using jquery, if that can solve the issue.</p>
  
  <p>Observed result:</p>
  
  <pre><code>id=1,1,2
  orderdate=2013-01-01
  quantity=12.2,15
  </code></pre>
  
  <p>Expected result:</p>
  
  <pre><code>  id=1
    orderdate=2013-01-01
    id=1
    quantity=12.2
    id=2
    quantity=15
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;form method='post' action='SaveOrder'&gt;
  
  Order id&lt;input name='id' type='text' value='1' /&gt;
  Date &lt;input name='orderdate' type='date' value='2013-01-01'/&gt;
  
  Row 1 id &lt;input name='id' type='text' value='1' /&gt;
  Quantity &lt;input name='quantity' type='text' value='12.2'/&gt;
  
  Row 2 id &lt;input name='id' type='text' value='2'/&gt;
  Quantity &lt;input name='quantity' type='text' value='15' /&gt;
  
  &lt;input type='submit' value='Save order'/&gt;    
  &lt;/form&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post)]
  public ActionResult SaveOrder(NameValueCollection form) 
  {
      for (int i = 0; i &lt; form.Count; i++)
          Console.WriteLine(form.GetKey(i)+"="+ form[i].ToString());
  }
  </code></pre>