Working with Parameters with Crystal Reports and ASP.NET 2.0
(Page 1 of 6 )
This is the second article in a series that covers programming with Crystal Reports with ASP.NET 2.0. In this article, we will focus on working with parameters using Crystal Reports and passing the parameter values from an ASP.NET 2.0 web site.
A
downloadable zip file is available for this article.
If you are new to Crystal report programming, I strongly suggest that you read the first article in this series, Programming Crystal Reports with ASP.NET 2.0. This article uses and enhances the solution (source code) provided at the above link.
The entire solution (source code) for this article is available as a free download in the form of a zip. The source code in this article has been developed using Microsoft Visual Studio 2005 Professional Edition on Microsoft Windows XP Professional Edition with Microsoft SQL Server 2005 Express Edition. I used the same version of Crystal Reports which comes with Visual Studio 2005 Professional Edition. I didn't test the code in any other tools/IDEs/servers/editions/versions. If you have any problems, please feel free to post in the discussion area.
Adding a single parameter to the Crystal Report at design time
Before proceeding further, open the "SampleWebSite01" website (available as a download with this article) and add a new Crystal Report (named "SampleParam1.rpt") focusing on the Orders table of the Northwind database. Make sure you add OrderID, CustomerID, EmployeeID and OrderDate to the report. All of this is explained in the first article of this series.
The following are the steps required to add a parameter to the Crystal report:
Using the "FieldExplorer," right click on "Parameter Fields" and click "New" as shown in the following figure (01).

Enter "Name" as "p_EmployeeID," "Prompting Text" as "Enter Employee ID," specify "Value Type" as "Number" and click on "OK" as shown below in figure 02.

Click on "Select Expert" on the tool bar, as highlighted in red in figure 03.

In the "Choose Field" dialog box, select "Orders.EmployeeID" and click on OK as shown in figure 04.

In the "Select Expert" dialog box, select the operator as "is equal to," select "{?p_EmployeeID}" as the value (shown in Figure 05) and click OK.

Next: Passing the value to Crystal Report Parameter dynamically: source code >>
More ASP.NET Articles
More By Jagadish Chaterjee