title: Dynamically binding of Dataset to RDLC Reports
body: <p>I would like to bind the dynamically dataset to the rdlc.  I can view the report if I use inline DataSource in ASPX file (static binding).  However, if I use the following codes, the Report viewer keeps showing "Loading.." Image.</p>
  
  <p>I have already check the dataset name and if I changed the dataset name to "Orders2", it shows me that required dataset "Orders" is not provided.  So, I add the GridView on the form and test my DataSet.  The dataset contains data and showing well with the GridView.</p>
  
  <p>The problem is only with the Report and I could not bind data dynamically to the ReportViewer.  Please help me.  Thanks.</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      DataSet ds = GetDataSet();
      ReportDataSource rds = new ReportDataSource("Orders", ds.Tables[0]);
      ReportViewer1.LocalReport.DataSources.Clear();
      ReportViewer1.LocalReport.DataSources.Add(rds);
      ReportViewer1.LocalReport.Refresh();
  
      GridView1.DataSource = ds;
      GridView1.DataBind();
  }
  
  private DataSet GetDataSet()
  {
      var conString = ConfigurationManager.ConnectionStrings["dotnetConnectionString"];
      string strConnString = conString.ConnectionString;
  
      SqlConnection conn = new SqlConnection(strConnString);
      conn.Open();
      string sql = "Select * FROM Orders";
  
      SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
      DataSet ds = new DataSet();        
      ad.Fill(ds);
  
      return ds;
  }
  </code></pre>
  
  <p>ASPX codes are as below:</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
      &lt;/asp:ScriptManager&gt;
      &lt;rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="600px" Width="800px"&gt;
          &lt;LocalReport ReportPath="Reports\Report.rdlc"&gt;
              &lt;DataSources&gt;
                  &lt;rsweb:ReportDataSource /&gt;
              &lt;/DataSources&gt;
          &lt;/LocalReport&gt;
      &lt;/rsweb:ReportViewer&gt;
      &lt;asp:GridView ID="GridView1" runat="server"&gt;
      &lt;/asp:GridView&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>