Reportviewer – Prompt for parameters in local mode

parametersreportviewer

Is it possible for the Microsoft ReportViewer control to prompt for parameters in local mode?

I have added a parameter to filter the report by, which can be mulitple values for the one parameter.

I have set the available Values property of the paramter to read a list of Values from a query.

I was hoping if I did not set parameter values in code the report would prompt for them like crystal reports does ( Im setting the datasource for the parameter available values )

I have done some research on this and as far as I can tell the only time the report would prompt for parameters is if the report is running in server processing mode.

Is this the case? I'm trying to avoid having to add controls to the page to select parameters to pass to the report.

Are available parameter properties relevent to the Local report or are they just there for both?

for completeness, here is the code im using to set the datasource for the report:

            //Set the report
            Reporting.Common.SetReportEmbeddedResource( this.ReportViewer1, "Reporting.Reports.BudgetEnquiryDrilldown.rdlc" );

            //Set the datasources
            this.ReportViewer1.LocalReport.DataSources.Add(
                new ReportDataSource(
                    "BudgetEnquiry",
                     Reporting.Repositories.BudgetEnquiryDrilldown.GetBudgetEnquiryRecords(
                            base.CurrentSageDatabase,
                            base.CurrentUser.UserID ) ) );

            this.ReportViewer1.LocalReport.DataSources.Add(
                new ReportDataSource(
                    "AccountNumber",
                    Reporting.Repositories.BudgetEnquiryDrilldown.GetAccountNumbers(
                        base.CurrentSageDatabase ) ) );

            this.ReportViewer1.LocalReport.DataSources.Add(
                new ReportDataSource(
                    "CostCentre",
                    Reporting.Repositories.BudgetEnquiryDrilldown.GetCostCentres(
                        base.CurrentSageDatabase ) ) );

            //Refresh the report
            this.ReportViewer1.LocalReport.Refresh();

Best Answer

I don't think you can using the ReportViewer per say, but it's easy to create a new form with the parameters needed and pass them to the report.

Look at this :


    Dim params As New List(Of Microsoft.Reporting.WinForms.ReportParameter)
' Add Parameters of type Microsoft.Reporting.Windows.ReportParameter
    params.Add(New Microsoft.Reporting.WinForms.ReportParameter("Test", "Whatever"))

    RptViewer.LocalReport.SetParameters(params)

In this case, the param test is given the value "whatever".