Reputation:
I got a problem in my vb Project, as from subject its clear that I have a problem in specifying many reports in one report viewer in one form. It's difficult to create many forms and adding report viewer in each form.
I have more than 100 reports.rdlc and want to show it in one report viewer by choosing multiple options in combobox or different criterias.
Upvotes: 0
Views: 10231
Reputation: 1
Just as tezzo said,
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.ReportPath = "Report2.rdlc"
ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", CType(d1, DataTable)))
ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter("ReportCriteria", criteria))
ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter("FileDate", fileDateString))
ReportViewer1.Visible = True
ReportViewer1.DataBind()
Changing the localreport reportpath to a different reportname is all you really need.
Upvotes: 0
Reputation: 4948
If you want the same form window to appear each time you change report in your combobox, just create a new instance of that form every time you go to generate the .rdlc report.
When you click this button, it will create two reports. One report will be generated from the method YourFirstReport()
and the other from YourSecondReport()
. Both using the same ReportViewer1 control from the same form using a new instance of rv
.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Create instance "rv" of your report viewer form
Dim rv As New frmReportViewer
rv.YourFirstReport()
rv = New frmReportViewer
rv.YourSecondReport()
End Sub
Public Sub YourFirstReport()
ReportViewer1.LocalReport.ReportEmbeddedResource = "YourProject.YourFirstReportName"
'...
'And so on..
End Sub
Public Sub YourSecondReport()
ReportViewer1.LocalReport.ReportEmbeddedResource = "YourProject.YourSecondReportName"
'...
'And so on..
End Sub
Take my example here, the square in red has a button that generates my frmReportViewer
every time I click on it. The green circles demonstrate my reports that pop up. Both these report utilize the same form.
Upvotes: 3
Reputation: 11115
You can create a single ReportViewer and set his property at runtime:
Then you can .RefreshReport().
Upvotes: 0