Tuesday, October 23, 2018

Windows Forms - Load local reports on microsoft report viewer dynamically

I started using the microsoft report viewer + their report designer its pretty good i'd say. I have one problem i can't solve though.

I want to have one form with the report viewer control and just send to this form the name of the report and the parameters it needs, and i suppose the data source ( i need to provide the data source each time i load a report? cause i assigned it inside the report designer).

Does anyone have an example on how to do that? I did some research but i didnt find something useful.

Now i am loading the reports like the example below.

 private void ReportViewer_Load(object sender, EventArgs e) { ReportDataSource dt = new ReportDataSource("Customer2",bindingSource1); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(dt); ReportParameter pm = new ReportParameter("id"); pm.Values.Add("1"); reportViewer1.LocalReport.SetParameters(pm); reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); } 

Windows Forms - Load local reports on microsoft report viewer dynamically Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team