我创建了2个报告billa4.rdlc和billa5.rdlc,我想根据用户选择的combobox选项将其中一个报告加载到reportviewer。 请帮帮我。 以下代码正在加载billa4.rdlc
Try
Dim P2 As New ReportParameter("pbillnum", billnoprint)
Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
Me.ReportViewer1.RefreshReport()
Catch ex As Exception
MsgBox("error")
End Try
答案 0 :(得分:0)
你有什么尝试?不要直接从设计模式设置报告源,按代码执行。
也许是这样的:
if( combooption.SelectedValue = 0) Then
Dim P2 As New ReportParameter("pbillnum", billnoprint)
Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
Me.ReportViewer1.ViewReport("billa4.rdlc")
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
Me.ReportViewer1.RefreshReport()
else
Dim P2 As New ReportParameter("pbillnum", billnoprint)
Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
Me.ReportViewer1.ViewReport("billa5.rdlc")
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
Me.ReportViewer1.RefreshReport()
End if