Monday, March 26, 2012

Hidden vs. Internal Parameters -- Got to be a better way...

We have an application that gets a report's parameters and parameter values. We're using SQL Server 2005. The problem is that we need a couple of the report's parameters to be non-prompting AND not read-only.

In our application, we dynamically build the UI based on the parameters and parameter values retrieved from the report, but we only want to display parameters that are PromptUser = true and not hidden and not read-only. Here's the code:

ReportingService.ReportingService2005 rs = new ReportingService.ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

string historyID = null;
bool forRendering = true;
ReportingService.ParameterValue[] values = null;
ReportingService.DataSourceCredentials[] credentials = null;
ReportingService.ReportParameter[] parameters = null;

parameters = rs.GetReportParameters(sReportAndPath, historyID, forRendering, values, credentials);

if ((parameters != null) && (parameters.Length > 0))
{
foreach (ReportingService.ReportParameter rp in parameters)
{
if (rp.PromptUser)
{
// Display parameter and parameter default values on screen
// Only display parameters that are NOT internal AND NOT hidden
// PromptUser property takes care of the internal
// hidden parameters appear to have a PromptUser = true
}
}
}

How can we do this?

If we set the parameter to internal, then it doesn't display, but we get an error later when we try to update the parameter value (because it's read-only). If we set the parameter to hidden, then it gets displayed on screen because the PromptUser property is true.

Basically, we want to be able to change the parameter value (thus NOT read-only), but, at the same time, not display on screen (PromptUser = false).

Hope this makes sense.

Any suggestions?

If the parameter is hidden, string.IsNullOrEmpty(rp.Prompt) == true && rp.PromptUser == true.sql

No comments:

Post a Comment