title: MVC4 Send Datatable to View
body: <p>I need to pass a list of TestModel into my view.  This list will then be used to populate a grid.  However, I want the members of TestModel to be created dynamically from headers in a datatable loaded from sqldatareader.</p>
  
  <p>Is this possible?  If so, how?  If not, are there any other alternatives for loading a grid in my view with the columns and rows from my datatable?</p>
  
  <p>If I strongly type my view using this:</p>
  
  <pre><code>@using System.Data;
  @model System.Data.DataTable
  </code></pre>
  
  <p>Then I get down to mapping the datatable to the grid</p>
  
  <pre><code>@{
      var grid = new WebGrid(Model, defaultSort: "Name");
  }
  </code></pre>
  
  <p>I get these errors:</p>
  
  <pre><code>The best overloaded method match for 'System.Web.Helpers.WebGrid.WebGrid(System.Web.HttpContextBase, string, int, bool, bool, string, string, string, string, string, string, string)' has some invalid arguments
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Argument 1: cannot convert from 'System.Data.DataTable' to 'System.Web.HttpContextBase'
  </code></pre>