.netvb.netreporting-servicesssrs-2008-r2reportbuilder3.0

SSRS ReportViewer control report parameters Visible and PromptUser properties always true


I have some VB.net code that retrieves all the report parameters for an SSRS report. According to the MSDN documentation the Visible and PromptUser properties should correlate to whether the report displays a prompt for that parameter (rather then just an error if not supplied). However in this sample code these properties always come back true. The code references the MS.ReportViewer.WebForms dll. I've tried version 10 and 11.

Public Function GetReportParameters(strPath As String) As List(Of Microsoft.Reporting.WebForms.ReportParameterInfo)
    Dim lstParams As New List(Of Microsoft.Reporting.WebForms.ReportParameterInfo)
    Dim objRV As New Microsoft.Reporting.WebForms.ReportViewer
    objRV.ServerReport.ReportServerUrl = New System.Uri("http://localhost/ReportServer/")
    objRV.ServerReport.ReportPath = strPath
    Dim oRptParams As Microsoft.Reporting.WebForms.ReportParameterInfoCollection = objRV.ServerReport.GetParameters
    For Each oRptParam As Microsoft.Reporting.WebForms.ReportParameterInfo In oRptParams
        Dim strName As String = oRptParam.Name
        Dim blnPromptUser As Boolean = oRptParam.PromptUser
        Dim blnVisible As Boolean = oRptParam.Visible
        lstParams.Add(oRptParam)
    Next
    Return lstParams
End Function

I have also tried this using LocalReport instead of ServerReport but it didn't help. As you can see from the report parameter properties in Report Builder there is a parameter set to hidden.

enter image description here


Solution

  • I found the same behavior.. weird but true.
    But for my purpose (to see if Visible is selected) I found a workaround.

    When selecting Hidden, the Report-Designer lets you enter a Prompt, but it will not be passed along into the ReportParameterInfo

    When selecting Internal, you can't even enter a Prompt.

    and as a Bonus, the Report-Designer forces you to enter a Prompt if Visible is selected.

    So I can conclude: ReportParameterInfo.Prompt is only and always filled, when Visible is selected.

    if (param.Prompt == "")
    {
        // Parameter not "Visible"
    }
    else 
    {
        // Parameter is "Visible"
    }
    
    If param.Prompt = "" Then
        ' Parameter not "Visible"
    Else
        ' Parameter is "Visible"
    End If