SSRS parameters are set programmatically, causing the state of ValidValueMissing

I am trying to get a username parameter and replace it with a value for the session username, so I can go to the stored procedure inside the DRL to create a timestamp for the table with that username. The "username" parameter is one of the RDL parameters that comes with the default value, and I'm trying to change it with the following code.

Replacing one of the ReportParameters parameters:

var userParameter = GetUserParameter(); if (userParameter != null) { newParameters.Remove(newParameters.FirstOrDefault(param => param.Name.Contains(CurrentUserParameterName))); newParameters.Add(userParameter); } 

Search ReportParameters username:

 var paremeters = ReportViewer.ServerReport.GetEditableHiddenParameters(); //finds parameter by its name, pelase view const value in CurrentUserParameterName var userParameter = paremeters.FirstOrDefault(param => param.Name.Contains(CurrentUserParameterName)); if (userParameter != null) { userParameter.Values.Clear(); userParameter.Values.Add(Utils.GetUserName()); } return userParameter; 

Set ServerReport parameters:

 ReportViewer.ServerReport.SetParameters(parameters); 

After starting the report, I get the message "Parameter" username "missing value"

When I debug and look in ServerReport.GetParameters() , I see that I have a ReportParameter username, I have values ​​(new values), but its state is "MissingValidValue".

What am I doing wrong? Thanks in advance, Eddie

+6
source share
1 answer

I finally managed to fix this problem thanks to this article: http://technet.microsoft.com/en-us/library/dd220464.aspx

If you specified the available values ​​for the parameter, the actual values ​​are always displayed as a drop-down list. For example, if you provide available values ​​for the DateTime parameter, a drop-down list for dates appears in the options bar instead of a calendar control. To ensure that the list of values ​​is consistent among the report and subheadings, you can set the data source option to use a single transaction for all queries in the data sets that are associated with the data source.

Since I entered the default value in the "available values" parameter in addition to the "default values" mark, the report tried to check the new session username, which was not indicated as the "available value". After I deleted the values ​​in the "available values", the new ReportParameter, which I provide in the encoding, should not be checked, and the report was successfully executed.

+6
source

Source: https://habr.com/ru/post/897075/


All Articles