Problem when trying to show / hide options in ASP.NET ReportViewer control
I have an SSRS report that is displayed to users in an ASP.NET ReportViewer control. The report has many parameters, and we use the parameter hints that the ReportViewer control offers. Depending on the specific report parameter, we only need to tell the user for a subset of the rest of the report parameters.
We could use linked reports and hide the corresponding parameters, but there are many possible combinations with this first parameter (it is multi-valued), so we don't want to do that. Instead, we have an ASP.NET ListBox that controls the first parameter, and when it changes, we use the ReportViewer.ServerReport.SetParameters () function to hide / show the parameters (it takes in the ReportParameter array and the ReportParameter constructor takes a boolean value to hide / show parameter).
Here's the problem. Everything works fine in our development environment. When we deploy a report and ASP.NET site to a production environment, the parameters are never displayed when calls to SetParameters () are called. We know the code is being called because we have supplied some debug output to be sure. The code for hiding the parameters works fine. It's just code that has to call certain parameters to be displayed again, doesn't work. Not only does it not display parameter hints, but the Visible property of that parameter is not set to true (checked with ReportViewer.ServerReport.GetParameters ()).
SQL Server 2005 SP3, , (Microsoft.ReportViewer.WebForms.dll). , ? ? , .
Edit: After further investigation, we further isolated the issue. I made a simple report with only one parameter without any DB connection. Then I created an aspx page with two buttons and a ReportViewer control connected to this report. 1 hides the parameter and button 1 shows the parameter (using the SetParameters () function as above). Even with such a simple scenario, the hide / show buttons work fine in the development environment, but we still have the same problem in the production environment (the show button doesn't work). We also tried this on another server on the network in a production environment and we have the same problem. So everything works fine in a development environment, but on two different servers outside of that environment, we seem to get the same problem.
Edit2: Below is the code for the test report page. The page has a ReportViewer, 2 buttons and a label for debug output. When showing hidden parameters doesn't work, the shortcut even shows that the Visible property remains false after the ShowParameter is called.
Public Partial Class TestReportPage
Inherits System.Web.UI.Page
Public Sub HideParameter(ByVal parameterName As String)
Dim parameters As ReportParameterInfoCollection = ReportViewer1.ServerReport.GetParameters()
ReportViewer1.ServerReport.SetParameters(New ReportParameter() {New ReportParameter(parameterName, GetParameterDefaults(parameterName, parameters), False)})
parameters = ReportViewer1.ServerReport.GetParameters()
lblTest.Text &= "Hide param " & parameterName & "; Is Visible: " & parameters(parameterName).Visible & "<br>"
End Sub
Public Sub ShowParameter(ByVal parameterName As String)
Dim parameters As ReportParameterInfoCollection = ReportViewer1.ServerReport.GetParameters()
ReportViewer1.ServerReport.SetParameters(New ReportParameter() {New ReportParameter(parameterName, GetParameterDefaults(parameterName, parameters), True)})
parameters = ReportViewer1.ServerReport.GetParameters()
lblTest.Text &= "Show param " & parameterName & "; Is Visible: " & parameters(parameterName).Visible & "<br>"
End Sub
Public Shared Function GetParameterDefaults(ByVal parameterName As String, ByVal parameters As Microsoft.Reporting.WebForms.ReportParameterInfoCollection) As String()
Dim paramDefaults() As String = {}
Dim i As Int16 = 0
For Each paramValue As String In parameters(parameterName).Values
ReDim Preserve paramDefaults(i)
paramDefaults(i) = paramValue
i = i + 1
Next
Return paramDefaults
End Function
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
HideParameter("foo")
End Sub
Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ShowParameter("foo")
End Sub
End Class
a source to share
Just for anyone who has ever had this problem, here's the reason we had this problem:
The problem was related to the difference in the environment. Even though the ReportViewer DLL was copied into the bin folder of the project (and thus copied to where the project was placed), this parameter issue is a bug in older versions of the ReportViewer control. To fix this problem, you need to obtain Microsoft Report Viewer Redistributable 2005 SP1. Apparently this fix was installed in a development environment. For some reason, the ReportViewer DLL was the same version on both sides. This may be due to the fact that the DLL was actually accessed from another location.
a source to share