Passing a parameter to Report Viewer
-
Monday, December 03, 2007 8:19 PM
Hi,
Is it possible to send a parameter to the report viewer inorder to display a particular customer details. I want to send customer-id to report viewer to see the details of particular customer.
How can i achieve this?
Hoping for reply.
Thankx.
Regards
Kashif Chotu
All Replies
-
Thursday, December 06, 2007 5:50 AM
Kashif Chotu,
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.
Code BlockPrivate Sub 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"
Dim pInfo As ReportParameterInfoCollection
Dim paramList As New Generic.List(Of ReportParameter)
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()
End Sub
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.
-
Saturday, December 08, 2007 7:59 AMThanks for reply.

