Using the Asp.net Report Viewer in VS2010 in Rem开发者_C百科ote mode we need to allow the user to use the default controls on the report viewer for entering in the parameters before running the report.
As permissions need to be set on the data we have a UserId hidden parameter on all the reports and the plan was to allow the user to enter in the parameters as normal and then we would add [programmatically] the userId parameter before the report is run.
The data in the report would then return the data that the user had permission to view.
[We use the SSRS web service to populate a treeview with a list of available reports for the user to select.]
I guess I'm having trouble with whats the best approach for this. I need to pass the userId parameter value to the ReportViewer and not to the server report.
I'm aware that you can use the web service to manage the parameters completely outside of the control but its not an option for us at the minute.
So in summary:
User Selects Parameters in the Report Viewer. Code behind adds the UserId parameter value either as the report is run or initially when its loaded and the viewer passes all the parameters to the server.
I'd appreciate any help that you could give.
Liam
Found the answer and it was simple enough after and maybe didn't justify the question but here it is in case anyone is running on a low baud rate like I was yesterday.
Add the following event to the report viewer
onsubmittingparametervalues="Viewer_SubmittingParameters"
and in the handler
protected void Viewer_SubmittingParameters(object sender, ReportParametersEventArgs e)
{
Microsoft.Reporting.WebForms.ReportParameter userIdParameter =
new Microsoft.Reporting.WebForms.ReportParameter();
userIdParameter.Name = "UserId";
userIdParameter.Values.Add(this.Username etc);
// Add to existing parameters
e.Parameters.Add(userIdParameter);
}
Liam
精彩评论