Setting the value of a Report Parameter Programmatically

Is there any way to set the value of a parameter from custom code

I am working with a simple string parameter called @City (the name of a city, used in the WHERE clause of a query). I have tried a number of approaches that all wind up doing something like this,

Report.Parameters!City.Value = "Fairhope"

Visual Studio Report Writer returns this error when the report is previewed, "Property 'Value' is 'ReadOnly'."

The City parameter is not marked "internal". I have tried it both normal and hidden; the result is the same.

How can I set the value of a report parameter in code




Answer this question

Setting the value of a Report Parameter Programmatically

  • skatterbrain

    You should set the "Default Value" property of the report parameter. The default value can use a constant, expressions, call custom code functions, or bound to a dataset field.

    After parameter values are selected, they cannot be changed later during the report execution - that's why you get the error in preview.

    -- Robert



  • Setting the value of a Report Parameter Programmatically