title: How to use rowspan in MVC-Razor, without javascript?
body: <p>How can I merge cells in a table using rowspan inside a Razor view?</p>
  
  <ul>
  <li>Without using javascript/jQuery.</li>
  <li>The table's source is an IEnumerable.</li>
  <li>Some of the items in the source will have the same value in a certain field and those are the one we want to merge in one cell.</li>
  <li>We don't know how many times a given value is repeated.</li>
  </ul>
  
  <p>The resulting HTML should be something like this:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;td rowspan="2"&gt;Column 1 row 1&lt;/td&gt;
          &lt;td&gt;Column 2 row 1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Column 2 row 2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td rowspan="3"&gt;Column 1 row 3&lt;/td&gt;
          &lt;td&gt;Column 2 row 3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Column 2 row 4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Column 2 row 5&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>EDIT to add the data source and desired result:</p>
  
  <p>The data source may be something like Products with Categories. Ex:</p>
  
  <h2>Categories</h2>
  
  <ul>
  <li>Electronics</li>
  <li>Groceries</li>
  </ul>
  
  <h2>Products</h2>
  
  <ul>
  <li>Laptop (Electronics)</li>
  <li>iPod (Electronics)</li>
  <li>TV (Electronics)</li>
  <li>Coffee (Groceries)</li>
  <li>Cookies (Groceries)</li>
  </ul>
  
  <h2>The result</h2>
  
  <pre><code>╔═════════════╦════════╗
  ║ Electronics ║ Laptop ║
  ║             ║ iPod   ║
  ║             ║ TV     ║
  ╠═════════════╬════════╣
  ║ Groceries   ║ Coffee ║
  ║             ║ Cookies║ 
  ╚═════════════╩════════╝
  </code></pre>
  
  <p>The only way I have in mind is using Linq to count how many times a value is on the list, but I wanted to know if someone have a better solution. Thanks!</p>