Wednesday, February 24, 2010

Crystal Report With Asp.NET – Data Set in Different Project

When architecting the system some types you might layering the application to Data Layer and Presentation Layer. Therefore you normally put the Dataset to the data layer, But your report in the presentation layer. Thus When you are creating the crystal report in Presentation Layer it is not showing the Data Set which is in the Data Layer.


There fore when you are creating the report using data set, it is shown as empty.

image   Thus you want to copy the dataset to the project. For that copy and paste the data set to the project.


Now you can design your report by adding the dataset as previous article. After design the report you can delete the dataset i the project (WebApplication)

Now we want to call the report when the page is loading.


protected void Page_Load(object sender, EventArgs e)

ReportDocument CollReport = new ReportDocument();
string reportPath = Server.MapPath("CrystalReport.rpt");

DataLayer.DataSetTableAdapters.Table1TableAdapter ta =
new DataLayer.DataSetTableAdapters.Table1TableAdapter();
// We have to refere Datalayer project

DataLayer.DataSet.Table1DataTable dt =
new DataLayer.DataSet.Table1DataTable();


CrystalReportViewer1.ReportSource = CollReport;

1 comment:

Anonymous said...

Thanks it helps a lot. Visit