Wednesday, March 28, 2012

Report Viewer/Default Parameters

Is it possible for one report to have different default parameters, based on the user viewing the report, when the report is accessed via the Report Viewer?

Thanks.

Assuming you are asking for viewing report through report server: default values can be (1) constant, (2) expression-based, or (3) dataset based.

Regarding (2): you could determine the default value based on the current userid, e.g =iif(User!UserId="abc", "Default1", "Default2")

Regarding (3): you could use the current user information in the query commandtext or as parameter into a stored procedure to dynamically determine the default value.

-- Robert

|||

If you are using the ReportViewer control in ASP.NET, you can set the value of the parameter programatically based on the current user identity:

this.ReportViewer1.ServerReport.ReportPath = "/SampleReports/Employee Sales Summary";

ReportParameter p = new ReportParameter("EmpID", "20");

this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { p });

No comments:

Post a Comment