1.
Open the Default.aspx page in Design mode.
2.
Navigate to the Reporting section in the Toolbox and find the
CrystalReportPartsViewer control. Drag this control onto the Default.aspx
page.
3.
Double click on the web page to view the code behind.
4.
Add the following using statements.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
5.
Add the following code to the Page_Load event.
ReportDocument customersReport = new ReportDocument();
string reportPath = Server.MapPath("Sales.rpt");
customersReport.Load(reportPath);
SetTableLocation(customersReport.Database.Tables);
CrystalReportPartsViewer1.ReportSource = customersReport;
6.
Add the SetTableLocation method.
private void SetTableLocation(Tables tables)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = @"YOURSERVER";
connectionInfo.DatabaseName = "AdventureWorks";
connectionInfo.UserID = "YOURSQLLOGIN";
connectionInfo.Password = "YOURPASSWORD";
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
}
7.
Be sure to change the ServerName, UserID, and Password to your settings.
8.
Click the Run button to start the project. Make sure the Default.aspx
page is set as the startup page. You should see the following page.
9.
Click on the $82,425,341.28 next to the United States. You should see
the following page.
10. This
displays all the states within the United States. The Next link will allow you
to scroll through the list. If you wanted to display more than 10 at a time
you can change the BatchSize property of the PartsViewer control.
11. Click
on the $308,827.13 next to Idaho. This will display the cities within Idaho
with an order. You should see the following page.
12. Click
on the $9,254.26 next to Sandpoint. This will drill into the individual detail
records that make up this total.