Reportviewer - Prompt for parameters in local mode?

梦想与她 提交于 2019-12-14 02:31:34

问题


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();

回答1:


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".




回答2:


Stuck with the same question and found this after googling

"In the absence of Report Server, the ReportViewer must obtain its data from your application. In local mode, your application is responsible for providing the necessary input to the report. That's why the ReportViewer doesn't display the parameter prompt area with local reports. Parameters and data are external to ReportViewer."

source:

http://webcache.googleusercontent.com/search?q=cache:c2GuADZEUSYJ:www.devx.com/dotnet/Article/30424/0/page/4+reportviewer+display+parameter+prompt+area&cd=11&hl=en&ct=clnk&gl=us&source=www.google.com



来源:https://stackoverflow.com/questions/5636184/reportviewer-prompt-for-parameters-in-local-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!