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

Comments

  • edited October 2013
    I'm starting with Webreports as well, so I'm interested in other peoples experiences.
    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);"
  • edited 1:29AM
    equi wrote: »
    I'm starting with Webreports as well, so I'm interested in other peoples experiences.
    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);"
    Hi, thank you for the answer.
    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");
    }
  • edited October 2013
    Do you see any data of the report at all (labels)?
    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:
    protected void WebReport1_StartReport(object sender, EventArgs e)
    {
       var report = new Report();
       report.Load(localFilepath);
       report.SetParameterValue("paramname", value);
       report.Prepare();
       (sender as WebReport).Report = report;
       (sender as WebReport).ReportDone = true;
    }
    
  • edited 1:29AM
    equi wrote: »
    Do you see any data of the report at all (labels)?
    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:
    protected void WebReport1_StartReport(object sender, EventArgs e)
    {
       var report = new Report();
       report.Load(localFilepath);
       report.SetParameterValue("paramname", value);
       report.Prepare();
       (sender as WebReport).Report = report;
       (sender as WebReport).ReportDone = true;
    }
    
    Yes i can see all labels, exept the labels in the filtered section, I set it to: [report_expenses.userId]== [userID] where [report_expenses.userId] is a my field in the datasource and [userID] is my parameter.
    I try the code your code too, but it doesn't show anything
  • edited October 2013
    Like I said, concerning WebReports, I'm a beginner myself.
    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.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.