title: Populate values in View Model List Object
body: <p>I have a problem where I am unable to get values filled by user in my view to List defined in ViewModel.</p>
  
  <p>I have View where in some fields will be filled manually as:</p>
  
  <pre><code>S.No   StyleName    JobType    Quantity
  1      ABC          Repair     2
  2      XYZ          Wash       3
  </code></pre>
  
  <p>My <code>ViewModel</code> is as below:</p>
  
  <pre><code>    public class IssueViewModel
      {          
          public List&lt;OrderItem&gt; Items { get; set; }              
      }
  </code></pre>
  
  <p>My <code>OrderItem</code> is defined as below</p>
  
  <pre><code>    public class OrderItem
      {
          public int OrderItemId { get; set; }
          public string StyleName { get; set; }
          public string JobType{ get; set; }
          public int Quantity { get; set; }
  
      }
  </code></pre>
  
  <p>Now problem is how to link this ViewModel List to View to get the Values in my <code>Items</code> list to be saved in DB.</p>
  
  <p>Its working fine if I define separate Lists for StyleName, JobType and Quantity. In that case my view is something like below: </p>
  
  <pre><code>&lt;table id="theTable"&gt;
    &lt;tr&gt;
      &lt;th&gt;Sr.No&lt;/th&gt;
      &lt;th&gt;Style Name&lt;/th&gt;
      &lt;th&gt;JobType&lt;/th&gt;
      &lt;th&gt;Quantity&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;
            @Html.TextBoxFor(model =&gt; model.StyleName)
              @*&lt;input type = "text" style="border:0px;" value = "" /&gt;*@
      &lt;/td&gt;         
      &lt;td&gt;
            @Html.TextBoxFor(model =&gt; model.JobType)
             @*&lt;input type = "text" style="border:0px;" value = "" /&gt;*@
      &lt;/td&gt;
      &lt;td&gt;
            @Html.TextBoxFor(model =&gt; model.Quantity)
              @*&lt;input type = "text" style="border:0px;" value = "" /&gt;*@
      &lt;/td&gt;    
    &lt;/tr&gt;
  &lt;/table&gt;         
  </code></pre>
  
  <p>If I use above I have to read 3 different loops to get values. I understand this is not right approach. </p>
  
  <p>I know for displaying we use for loop but here I need to accept values filled by user. I searched a lot for this but didn't find any solution. Please advise. Thanks</p>