Can you set an Internal parameter using the Report Viewer control?

倖福魔咒の 提交于 2019-12-11 18:31:05

问题


Is it possible to set an internal parameter value using the Report Viewer control?

rv.ServerReport.SetParameters(new ReportParameter[] { new ReportParameter("Username", User.Identity.Name) });

{"The report parameter 'Username' is read-only and cannot be modified. (rsReadOnlyReportParameter)"}

I've heard that you can only set an internal parameter using the Report Viewer...but it seems an internal parameter is just that...internal. To be clear, an internal parameter on the server side is one where both Hide and Prompt are not checked on the parameter definition. If Hide is checked (hidden parameter), the parameter can still be passed in via a query string or on a subscription.


回答1:


MSDN - Creating Report Parameters and Setting Report Parameter Properties:

Hidden and Internal Parameters

You can set options that control parameter visibility in the published report. Setting the Hidden and Internal options provides different levels of visibility. You can hide the parameter on the parameter input area of the published report, yet set values for it on a report URL or in a subscription definition. If you set a parameter to Internal, it is not exposed in any way except in the report definition. An internal parameter must have a default value, which can be null if the Allow null value option has been selected.


Update, after a bit of testing:

This is actually a confusing definition. The parameter is exposed in Report Viewer and the value can be easily overridden in the report properties and the properties of a linked report.

You are still unable to set the value of an internal parameter from the URL or from the drill-down action from another report. It is visible when you create the action but when you try to drill-down you get the error: The report parameter 'name' is read-only and cannot be modified. I wouldn't imagine you will be able to modify the value from code either, but I haven't tested that.




回答2:


I had the same issue. I was sending to SSRS by URL some parameters. I needed to validate/edit the parameter if contains certain character. something like that:

=IIF(Parameters!Par1.Value Like "*]","[Table1].[Field1].&[" + Parameters!Par1.Value + "]]","[Table1].[Field1].&[" + Parameters!Par1.Value + "]")

In the Parameter Definitions. in "Select Parameter Visibility" I had marked the option: "Internal". I changed to "Hidden" and it allowed me to edit the parameter. why? no clues. but now is working



来源:https://stackoverflow.com/questions/32311741/can-you-set-an-internal-parameter-using-the-report-viewer-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!