title: How to get WebGrid column names dynamically
body: <p>I have a table which will have a few fixed columns and then a lot of dynamic ones depending upon how the pivot results.</p>
  
  <p>So this works just fine:</p>
  
  <pre><code>@{
  
      var db = Database.Open("STUDENT");
      var TeacherID = 15313;
  
      var selectCommand = "PBIS_ReviewBehaviors  @0, @1"; 
  
      var selectedData0 = db.Query(selectCommand, TeacherID, 0);
      var grid0 = new WebGrid(source: selectedData0, rowsPerPage: 30); 
  
      List&lt;WebGridColumn&gt; cols0 = new List&lt;WebGridColumn&gt;();
  
  }
  </code></pre>
  
  <p>and then the body:</p>
  
  <pre><code>&lt;div&gt;
      @grid0.GetHtml(
          tableStyle: "grid",
          headerStyle: "head",
          alternatingRowStyle: "alt"// ,
       //   columns: cols
      )
  &lt;/div&gt;
  </code></pre>
  
  <p>however I really want to be able to do some spcific things with some of my fixed columns -  in order to do that i need to know who to get the column names in Data0 or Grid0 so then I can build up a list called cols and use it:</p>
  
  <p>something like</p>
  
  <pre><code>foreach (column name in my grid)
  {
      if column name = "StudentID"
  
  cols0.Add(grid0.column(    format: @&lt;a href="~/InsertStudent?StudentID=@item.StudentID"&gt;Details&lt;/a&gt;   );
  
  else
  
  cols0.Add(grid0.column( the column name );
  
  }
  </code></pre>
  
  <p>Alas I am very new to .net and do not know how I get my list of column names and then use them specifically.    I have hopefully made the pseudocode clear enough with my intentions.</p>