title: How can I return multiple datasets from a Controller?
body: <p>Returning a single DataTable from a Controller works fine for me:</p>
  
  <pre><code>public ActionResult Index()
  {
      DataTable dtable = new DataTable();
      dtable = SQL.ExecuteSQLReturnDataTable(SQL.SelectUnitsQuery, CommandType.Text, null);
      ViewBag.Units = dtable;
      return View(dtable);
  }
  </code></pre>
  
  <p>I'm able to access it from the corresponding View like so:</p>
  
  <pre><code>@using System.Data
  @{
      ViewBag.Title = "Platypus Report Scheduler";
  
      DataTable ds = ViewBag.Units as DataTable;
      var rows = from x in ds.AsEnumerable()
                 select new
                 {
                     unit = x.Field&lt;string&gt;("unit")
                 };
  }
  </code></pre>
  
  <p>But I need to reference multiple datasets; I tried this in the Controller:</p>
  
  <pre><code>public ActionResult Index()
  {
      DataTable dtable = new DataTable();
      dtable = SQL.ExecuteSQLReturnDataTable(SQL.SelectUnitsQuery, CommandType.Text, null);
      ViewBag.Units = dtable;
  
      DataTable rpts = new DataTable();
      rpts = SQL.ExecuteSQLReturnDataTable("select ReportName from ReportsLU", CommandType.Text, null);
      ViewBag.Reports = rpts;
  
      return View(dtable, rpts);
  }
  </code></pre>
  
  <p>...but it won't compile; I get, "<em>Argument 1: cannot convert from 'System.Data.DataTable' to 'string'" for "dtable</em>" and the same error for arg 2 ("rpts"). Also, "<em>The best overloaded method match for 'System.Web.Mvc.Controller.View(string, string)' has some invalid arguments</em>"</p>
  
  <p>What is the way to work around this? Return a generic list of DataTable from the Controller? Populate the subsequent DataTables directly in the View? Or...???</p>