title: How to bind dynamically datasource to reportviewer on windows forms c#
body: <p>I have created windows form that acts as report loader. I have created also two RDLC reports by report wizard and it automatically created dataset for those two reports. Now I have two datasets: sparcsn4DataSet.xsd and sparcsn4DataSet1.xsd that are using stored procedure and passes two parameters (dateFrom/ dateTo). I have a problem with binding dataset depending on the status: </p>
  
  <pre><code>if (idRep.Equals("extraMove"))
  </code></pre>
  
  <p>It is quite easy to bind dataset to reportview, if you have one report. </p>
  
  <p><img src="https://i.stack.imgur.com/d0NTv.png" alt="Binding">
  but what if you have more than one? I can always create another form with another reportviewer but this is not an option (what if you have 10 reports/datasets), this is definitely out of question?</p>
  
  <p>There should be a way to bind dataset to reportviewer... Does anyone have idea, how I can solve binding problem depending on the status?</p>
  
  <pre><code>if (idRep.Equals("extraMove"))
          {
              this.AGCT_ServiceEventReportTableAdapter.Fill(this.sparcsn4DataSet.AGCT_ServiceEventReport, d1,d2);
          }
          else if (idRep.Equals("stripStuff"))
          {
              this.AGCT_StripStuffReportTableAdapter.Fill(this.sparcsn4DataSet1.AGCT_StripStuffReport, d1, d2);
          }
          else
          {
              MessageBox.Show("Ooops, something went wrong...!");
          }
  </code></pre>
  
  <p>This is ReportForm.cs that have reportviewer on it:</p>
  
  <pre><code>namespace NavisReportLoader
  {
      public partial class ReportForm : Form
      {
      public DateTime d1;
      public DateTime d2;
      public string dat1;
      public string dat2;
      public string idRep;
      public ReportForm()
      {
          InitializeComponent();
      }
      public void passParam(string dateFrom, string dateTo, string date1, string date2)
      {
          //ispravi ovo
         d1 = Convert.ToDateTime(dateFrom);
         d2 = Convert.ToDateTime(dateTo);
         dat1 = date1;
         dat2 = date2;
      }
      public void report(string id)
      {
          idRep = id;
      }
      private void ReportForm_Load(object sender, EventArgs e)
      {
  
          ReportParameter[] param = new ReportParameter[2];
          param[0] = new ReportParameter("date1", dat1);
          param[1] = new ReportParameter("date2", dat2);
          this.reportViewer1.LocalReport.SetParameters(param);
  
          if (idRep.Equals("extraMove"))
          {
              this.AGCT_ServiceEventReportTableAdapter.Fill(this.sparcsn4DataSet.AGCT_ServiceEventReport, d1,d2);
          }
          else if (idRep.Equals("stripStuff"))
          {
              this.AGCT_StripStuffReportTableAdapter.Fill(this.sparcsn4DataSet1.AGCT_StripStuffReport, d1, d2);
          }
          else
          {
              MessageBox.Show("Ooops, something went wrong...!");
          }
  
          this.reportViewer1.RefreshReport();
      }
      }
     }
  </code></pre>