Share via


ReportParameterInfo Class

 

Encapsulates information about report parameters.

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

Inheritance Hierarchy

System.Object
  Microsoft.Reporting.WinForms.ReportParameterInfo

Syntax

public sealed class ReportParameterInfo
public ref class ReportParameterInfo sealed 
[<Sealed>]
type ReportParameterInfo = class end
Public NotInheritable Class ReportParameterInfo

Properties

Name Description
System_CAPS_pubproperty AllowBlank

Indicates whether an empty string is a valid value for the parameter. Read-only.

System_CAPS_pubproperty AreDefaultValuesQueryBased

Indicates whether the default values of the parameter are based on a query. Read-only.

System_CAPS_pubproperty AreValidValuesQueryBased

Indicates whether the parameter's valid values are based on a query. Read-only.

System_CAPS_pubproperty DataType

Gets the data type of the parameter. Read-only.

System_CAPS_pubproperty Dependencies

Gets a list of parameters whose values are used to retrieve additional parameter values in a query. Read-only.

System_CAPS_pubproperty Dependents

A list of parameters that use the value of this parameter as parameters into queries to retrieve ValidValues and/or F:Microsoft.SqlServer.ReportingServices.ReportParameter.DefaultValues.

System_CAPS_pubproperty ErrorMessage

Gets the error message that is returned when the parameter fails validation. Read-only.

System_CAPS_pubproperty IsQueryParameter

Indicates whether the parameter is used in a query to an external data source. Read-only.

System_CAPS_pubproperty MultiValue

Indicates whether the parameter can be a multi-value parameter. Read-only.

System_CAPS_pubproperty Name

Gets the name of the parameter. Read-only.

System_CAPS_pubproperty Nullable

Indicates whether the value of the parameter can be null. Read-only.

System_CAPS_pubproperty Prompt

The text that prompts the user to provide parameter values.

System_CAPS_pubproperty PromptUser

Indicates whether the user is prompted for the value of the parameter.

System_CAPS_pubproperty State

Describes the state of the parameter. Read-only.

System_CAPS_pubproperty ValidValues

Gets the available valid values for the parameter. Read-only.

System_CAPS_pubproperty Values

Gets the values for the parameter.

System_CAPS_pubproperty Visible

Determines whether the parameter can be displayed in the user interface.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

The ReportParameterInfo class can be used to determine parameter requirements for a report at runtime.

Examples

Legacy Code Example

The following code sample assumes a WinForms application with a ReportViewer control. The code programmatically loads a sample report from the report server and iterates through the parameters encapsulated in the ReportParameterInfoCollection property of the T:Microsoft.ReportingServices.ServerReport object, showing information about each report parameter.

[C#]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace ParamSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            // Set Processing Mode
            reportViewer1.ProcessingMode = ProcessingMode.Remote;

            // Set report server and report path
            reportViewer1.ServerReport.ReportServerUrl = new
            Uri("https://localhost/reportserver");
            reportViewer1.ServerReport.ReportPath = 
               "/AdventureWorks Sample Reports/Employee Sales Summary";

            // Display the parameters for this report
            DumpParameterInfo(reportViewer1.ServerReport);

            // Set the parameters for this report
            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();


        }

        public void DumpParameterInfo(ServerReport sReport)
        {
            ReportParameterInfoCollection pInfo = sReport.GetParameters();

            if (pInfo.Count == 0)
            {
                Console.WriteLine("<No parameters are defined for this report>");
            }
            else
            {
                Console.WriteLine("===========================================================================");
                Console.WriteLine("Parameter Info for " + sReport.ReportPath);

                foreach (ReportParameterInfo p in pInfo)
                {
                    Console.WriteLine("----------------------------------------------------------------------");
                    Console.WriteLine("Parameter Name: {0}", p.Name);
                    Console.WriteLine("Data Type: {0}", p.DataType);
                    Console.WriteLine("State: {0}", p.State);
                    Console.WriteLine("Allow Blank? {0}", p.AllowBlank);
                    Console.WriteLine("Nullable? {0}", p.Nullable);
                    Console.WriteLine("Prompt User? {0}", p.PromptUser);
                    Console.WriteLine("User Prompt: {0}", p.Prompt);
                    Console.WriteLine("Visible? {0}", p.Visible);
                    Console.WriteLine("MultiValued? {0}", p.MultiValue);
                    Console.WriteLine("Default values query-based? {0}", p.AreDefaultValuesQueryBased);
                    Console.Write("Default value(s): ");

                    // Show a list of default values for the report params
                    IList<string> dvList = p.Values;
                    int t;

                    if (dvList.Count != 0)
                    {

                        t = 1;

                        foreach (string dv in dvList)
                        {
                            if (t != dvList.Count)
                            {
                                t++;
                                Console.Write(dv + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(dv);
                                else
                                    Console.WriteLine("or " + dv);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no default values defined>");
                    }

                    Console.WriteLine("Valid values query based? {0}", p.AreValidValuesQueryBased);
                    Console.Write("Valid values: ");

                    // Show a list of valid values for the report params

                    IList<ValidValue> vvList = p.ValidValues;

                    if (vvList != null)
                    {

                        t = 1;

                        foreach (ValidValue vv in vvList)
                        {
                            if (t != vvList.Count)
                            {
                                t++;
                                Console.Write(vv.Value + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(vv.Value);
                                else
                                    Console.WriteLine("or " + vv.Value);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no valid values defined>");
                    }

                    Console.Write("Dependent parameters: ");

                    ReportParameterInfoCollection dpInfo = p.Dependencies;
                    t = 1;

                    if (dpInfo.Count != 0)
                    {

                        foreach (ReportParameterInfo dp in dpInfo)
                        {
                            if (t != dpInfo.Count)
                            {
                                t++;
                                Console.Write(dp.Name + ", ");
                            }
                            else
                            {
                                if (t == 1)
                                    Console.WriteLine(dp.Name);
                                else
                                    Console.WriteLine("or " + dp.Name);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("<no dependent parameters defined>");
                    }

                }

            }
            Console.WriteLine("----------------------------------------------------------------------");
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.Reporting.WinForms Namespace

Return to top