I have 4 forms in my program. On form4 there is a TabControl which on its 4th TabPage I have put a ReportViewer.
There are some TextBoxes and ComboBoxes on form2 and form3.
There is a button called 'showResultButton' on 3rd TabPage on form4. When the user clicks this button I want to show the results on the ReportViewer. This results should contain the texts that the user has previously entered in the TextBoxes of form2 and form3 and the items of ComboBoxes that have previously been chosen.
How can I do this?
Thanks.
Loading
Roei BarPosted Sep 14, 2009, 4:44 PM
According to your question on passing parameter to Report Viewer, I would like to provide you the suggestions as follows:
1. Please consider to use Microsoft.Reporting.WinForms.ServerReport.SetParameters method that sets report parameter properties for the report.
The following code example shows how to load a server report into the ReportViewer control and set parameters on the report.
private void SetReportParameters()
{
//Set Processing Mode
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
// Set report server and report path
ReportViewer1.ServerReport.ReportServerUrl =
new Uri("http://localhost/reportserver");
ReportViewer1.ServerReport.ReportPath =
"/AdventureWorks Sample Reports/Employee Sales Summary";
ReportParameterInfoCollection pInfo ;
List<ReportParameter> paramList;
paramList.Add(new ReportParameter("EmpID", "288", False));
paramList.Add(new ReportParameter("ReportMonth", "12", False));
paramList.Add(new ReportParameter("ReportYear", "2003", False));
ReportViewer1.ServerReport.SetParameters(paramList);
pInfo = ReportViewer1.ServerReport.GetParameters();
' Process and render the report
ReportViewer1.RefreshReport();
}
2. You can also take a look at the article below:
Walkthrough: Creating a ReportViewer Report
This walkthrough shows how to create a simple table report in a Microsoft Visual Studio 2005 Windows application project based on the AdventureWorks sample database. You will add a report template to your project, set up connection information for the AdventureWorks database, define a query, add a table data region, and add a ReportViewer Windows Forms control to a Windows Form so the report can be viewed by users of the application.
Hope that can help you.
AtaPosted Sep 14, 2009, 6:17 AM
But I am a bigginer in C# programming. Could you please explain the solution in more detail according to the information in my previous post?
Your attention to this matter is highly appreciated.
Roei BarPosted Sep 14, 2009, 3:53 AM
so just add the parameters to the report as you wish to run them and then from the code add to the ReportViewer Url the "?" + QueryParames just like in Normal ASP.NET