title: How to add an item to a List<> in View in ASP.NET MVC
body: <p>In the view I have a Model that consists of 2 Lists. The <code>Model.Ingredients</code> is full of Ingredient objects, the second one <code>UsedIngredients</code> is initialized but empty. </p>
  
  <p>If the user clicks on an ingredient i want to add it to the empty list, because i want to pass that list to a partial view. </p>
  
  <pre><code>@foreach (var item in Model.Ingredients)
  {
      if (item.Type == "spirit")
      {
          &lt;a onclick="@Model.UsedIngredients.Add(item)"&gt;@item.Name&lt;/a&gt;
      }
  }
  </code></pre>
  
  <p>If I Try this I get an error:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'void' to 'object'.</p>
  </blockquote>
  
  <p>I have the list initialized correctly i think:</p>
  
  <pre><code>List&lt;Models.Extended.Ingredient&gt; list = new List&lt;Models.Extended.Ingredient&gt;();
  creator.UsedIngredients = list;
  </code></pre>