问题
I added a Parameter to report.rdlc called "ReportTitle". It is text and allows blank values and nulls. I have tried different ways to pass the parameter value to no avail. This is what I've tried so far:
Dim parReportParam1 As New ReportParameter("ReportTitle", "THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {parReportParam1})
Does not work!
Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
params(0) = New Microsoft.Reporting.WinForms.ReportParameter("ReportTitle", "THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(params)
Nothing!
Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
params(0) = New Microsoft.Reporting.WinForms.ReportParameter
params(0).Name = "ReportTitle"
params(0).Values.Add("THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(params)
Nope!
I don't know what to try anymore. Do I have to set something on the reportviewer or on the designer to allow parameter values. Any help is greatly appreciated it.
回答1:
I found The Aswer, You need to remember to put parameters after you pick the path to the Report never before.
I had exacly the same problem, everything was fine till I put parameters to the Raport and I had spent two hours before I found the cause.
回答2:
This worked for me:
Dim paramStoreNo As New ReportParameter("StoreNo", iSTORE_NO)
Dim reportparameters() As ReportParameter = {paramStoreNo}
InventoryTableAdapter.Fill(Me.DataSet1.Inventory, iSTORE_NO)
Me.ReportViewer1.LocalReport.SetParameters(reportparameters)
Me.ReportViewer1.RefreshReport()
回答3:
Maybe accidentally you have set available values for parameter to just null
or some other values in report.rdlc
. If so goto parameter properties and set Available Values
to None
and try again.
回答4:
If your problem is that you cant see your parameter value at your report, Can you try adding a refresh in your report viewer code page.
Add this at the end of your code
Reportviewer.localreport.refresh()
The problem might be because the page loaded before the application finished passing the values, so refresh it so it can reload with the parameter values at hand.
回答5:
I used the following code and it works fine:
For Each param As WinForms.ReportParameterInfo In ReportViewer1.LocalReport.GetParameters()
If param.name = "ReportTitle" Then
ReportViewer1.LocalReport.SetParameters(New WinForms.ReportParameter(param.Name, "THIS IS MY TITLE"))
End If
Next
Me.ReportViewer1.RefreshReport()
来源:https://stackoverflow.com/questions/27806245/vb-net-report-viewer-parameters