title: How to display spreadsheet style result on screen
body: <p>I have a result set of a class in List Results; format</p>
  
  <pre><code>public class Result
  {
   public string StudentName {get; set;}
   public string Subject {get; set;}
   public string Marks {get; set;}
  }
  </code></pre>
  
  <p>so i want to display it in Spreadsheet style like this.</p>
  
  <p><img src="https://i.stack.imgur.com/g34Ze.png" alt="enter image description here"></p>
  
  <p>What should be best approach to display it on MVC View? </p>
  
  <pre><code>&lt;table class="table table-bordered table-hover"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Subjects &lt;span class="glyphicon glyphicon-arrow-right pull-right"&gt;&lt;/span&gt;&lt;/th&gt;
              @foreach (var sub in subjects)
              {
                  &lt;th&gt;@sub&lt;/th&gt;
              }
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in students)
          {
              &lt;tr&gt;
                  &lt;td&gt;@item&lt;/td&gt;
                  @for (int i = 0; i &lt; subjects.Count(); i++)
                  {
                       var etc = Model.FirstOrDefault(m =&gt; m.StudentName == item &amp;&amp; m.Subject == subjects.ElementAt(i));
                      &lt;td&gt;@etc.Marks&lt;/td&gt;
                  }
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Note subjects and students are distinct() values from model</p>