title: bind report to reportviewer in web mvc2
body: <p>I have asp.net MVC2 application. 
  I am using VS2008 and want to hook up generated report from my controller to reportviewer.</p>
  
  <p>any ideas?</p>
  
  <p>so far i have this code
  "Controller"</p>
  
  <pre><code>//should pass data to report
   public ActionResult GenerateReport()
        {
  
  
          LocalReport report = new LocalReport();
          report.ReportPath = Server.MapPath("~/Reports/KingsCourt.rdlc");
  
          List&lt;InvoiceRow&gt; rows = new List&lt;InvoiceRow&gt;();
  
          rows.Add(new InvoiceRow { name = "Testing item", value = (decimal)25.85 });
          rows.Add(new InvoiceRow { name = "Testing item2", value = (decimal)5.15 });
          ReportDataSource source = new ReportDataSource("InvoiceRow", rows);
          report.DataSources.Add(source);
  
          ViewData["InvoiceRow"] = report;
          return View();
        }
  </code></pre>
  
  <p>and View page:</p>
  
  <pre><code> &lt;form id="form1" runat="server"&gt;
  
    &lt;h2&gt;GenerateReport&lt;/h2&gt;
    &lt;rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
        Font-Size="8pt" Height="400px" Width="400px"&gt;
      &lt;LocalReport ReportPath="Reports\KingsCourt.rdlc"&gt;
        &lt;DataSources&gt;
          &lt;rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="InvoiceRow" /&gt;
        &lt;/DataSources&gt;
      &lt;/LocalReport&gt;
  
  
    &lt;/rsweb:ReportViewer&gt;    
  
    &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Rows" 
        TypeName="Accounts.Classes.Invoices"&gt;&lt;/asp:ObjectDataSource&gt;
   &lt;/form&gt;
  </code></pre>