title: ReportViewer 2010 Not Loading Datasource from code
body: <p>I have created a project with a simple RDLC report in ASP.NET which when I bind the <code>DataSource</code> of the report at design time using a <code>SqlDataSource</code> everything works just fine. But if I remove the binding and try to set the <code>DataSource</code> from code then the report seems to never stop loading.</p>
  
  <p>I've worked with this on WinForms apps in the past and had no problems, but this is the first time I've tried to do it in ASP.NET, with no luck.</p>
  
  <p>Here's the code I'm using to set the <code>DataSource</code> in the <code>Page_Load</code> event. As I said using the same <code>SqlDataSource</code> that works if it's bound in the <code>.aspx</code> page.</p>
  
  <pre><code>ReportViewer1.Reset()
  ReportViewer1.ProcessingMode = ProcessingMode.Local
  ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc")
  ReportViewer1.LocalReport.DataSources.Clear()
  ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", SqlDataSource1))
  ReportViewer1.LocalReport.Refresh()
  </code></pre>
  
  <p>Even if I set the report directly in the reportviewer control and chop the code down to just...</p>
  
  <pre><code>ReportViewer1.LocalReport.DataSources.Clear()
  ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", SqlDataSource1))
  ReportViewer1.LocalReport.Refresh()
  </code></pre>
  
  <p>...it still does the same.</p>
  
  <p>Also, in Visual Studio while the report is loading you can see that a huge amount of script blocks are constantly being generated (the listbox keeps growing):</p>
  
  <p><img src="https://i.stack.imgur.com/PStfc.png" alt="Visual Studio"></p>
  
  <p>While this is going on the loading spinner is just going round halfway, restarting and repeating. The page isn't reloading though.</p>
  
  <p>Any thoughts?</p>