ServerReport.SetParameters Method (IEnumerable<ReportParameter>)

 

Sets report parameter properties for the report.

Namespace:   Microsoft.Reporting.WinForms
Assembly:  Microsoft.ReportViewer.WinForms (in Microsoft.ReportViewer.WinForms.dll)

Syntax

public override void SetParameters(
    IEnumerable<ReportParameter> parameters
)
public:
virtual void SetParameters(
    IEnumerable<ReportParameter^>^ parameters
) override
override SetParameters : 
        parameters:IEnumerable<ReportParameter> -> unit
Public Overrides Sub SetParameters (
    parameters As IEnumerable(Of ReportParameter)
)

Parameters

Remarks

The parameters specified for the M:Microsoft.Reporting.WinForms.ServerReport.SetParameters(Microsoft.Reporting.WinForms.ReportParameter[]) method must be defined in the report definition.

Examples

Legacy Code Example

The following code example shows how to load a server report into the ReportViewer control and set parameters on the report.

private void SetReportParameters() {
   // Set Processing Mode
   reportViewer1.ProcessingMode = ProcessingMode.Remote;

   // Set report server and report path
   reportViewer1.ServerReport.ReportServerUrl = new
      Uri("https://<ServerName>/reportserver");

   reportViewer1.ServerReport.ReportPath = 
      "/AdventureWorks Sample Reports/Employee Sales Summary";

   List<ReportParameter> paramList = new List<ReportParameter>();

   paramList.Add(new ReportParameter("EmpID", "288", false));
   paramList.Add(new ReportParameter("ReportMonth", "12", false));
   paramList.Add(new ReportParameter("ReportYear", "2003", false));

   this.reportViewer1.ServerReport.SetParameters(paramList);

   // Process and render the report
   reportViewer1.RefreshReport();
}
Private Sub SetReportParameters()
   'Set Processing Mode
   ReportViewer1.ProcessingMode = ProcessingMode.Remote

   ' Set report server and report path
   ReportViewer1.ServerReport.ReportServerUrl = _
      New Uri("https://<ServerName>/reportserver")

   ReportViewer1.ServerReport.ReportPath = _
      "/AdventureWorks Sample Reports/Employee Sales Summary"

   Dim pInfo As ReportParameterInfoCollection
   Dim paramList As New Generic.List(Of ReportParameter)

   paramList.Add(New ReportParameter("EmpID", "288", False))
   paramList.Add(New ReportParameter("ReportMonth", "12", False))
   paramList.Add(New ReportParameter("ReportYear", "2003", False))

   ReportViewer1.ServerReport.SetParameters(paramList)


   pInfo = ReportViewer1.ServerReport.GetParameters()

   ' Process and render the report
   ReportViewer1.RefreshReport()
End Sub

See Also

SetParameters Overload
ServerReport Class
Microsoft.Reporting.WinForms Namespace

Return to top