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
source share