WebReport and parameters
Hi all,
I created a simple report with a parameter called: parmUserId and I use it to filter my data in a query
So I add to an aspx page the control WebReport and I set the ReportFile property to my frx file.
I pass the value of my parameter in this way:
WebReport1.Report.SetParameterValue("parmUserId", "username");
but it seems the parameter is always blank because the query is always empty
Can anyone help me?
Thank you
I created a simple report with a parameter called: parmUserId and I use it to filter my data in a query
So I add to an aspx page the control WebReport and I set the ReportFile property to my frx file.
I pass the value of my parameter in this way:
WebReport1.Report.SetParameterValue("parmUserId", "username");
but it seems the parameter is always blank because the query is always empty
Can anyone help me?
Thank you
Comments
Have you tried the steps proposed in this thread:
http://www.fast-report.com/en/forum/?p=/discussion/7733
It quotes from the documentation:
"To pass a value to the report parameter, use the SetParameterValue method of the Report
object. This method was described in details in the "Working with Windows.Forms" chapter.
To use this method in ASP.NET, you need to create the event handler for the StartReport
event of the WebReport component. The report can be accessed through the WebReport.
Report property:
webReport1.Report.SetParameterValue("MyParam", 10);"
I have already the code to set parameter value in the event StartReport and it still doesn't work.
The complete code is this:
protected void WebReport1_StartReport(object sender, EventArgs e)
{
WebReport1.Report.SetParameterValue("parmUserId", "username");
}
I'm testing with a different scenario (I don't set it to a reportfile but I get the prepared report data from a database). Did you try to set the property ReportDone to true in the StartReportHandler? Like (sender as WebReport).ReportDone = true; or WebReport1.ReportDone = true.
Setting ReportDone to true was what was needed in my case to show the report.
What worked for me as well:
I try the code your code too, but it doesn't show anything
Could you attach your report? You can delete the connectionstring value when you edit your report with a text editor. I'm interested in how you bind your parameter to the query. For whatever reasons, I sometimes had problems with getting the parameters to work properly, too.
My queries for an MSSQL-DB usually look like this: Select * from table where column = @columnValue. In the next step of the query assistant, I define a parameter and set the name to the one I used (columnValue) and set the expression to the parameter ([userID] for you).
I think it will be difficult to find the reason why it's not working in your case without seeing the report. I can think of two reasons:
- The parameter is not set correctly. To verify that simply drag the parameter on the report so that its value is shown.
- Second possiblity, show the data without filtering to make sure that it's the query in combination with the parameter that is not working.