How do I get the ASP.NET Contr开发者_JAVA百科ols for Crystal Reports in Visual Studio 2008? I've downloaded and installed a lot of things, but the guidance on the SAP website isn't very helpful to me.
What do I need to download and install on my machine to create an ASP.NET application which surfaces Crystal Reports?
I think Crystal Report is intergated with VS long time ago.Even there is a Reporting Tab that is shown in Toolbox.How to use it well,Simple Add Crystal Report file to your project from Add item option and follow the wizard.
How to bind it to your web site is also simple.Add Crystal report View control from toolbox to the your web form.Then do
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument document = CreateReportDocument("MyReportFile");
CrystalReportViewer1.ReportSource = document;
}
public static ReportDocument CreateReportDocument(string crystalReportName)
{
ReportDocument crdocument = new ReportDocument(); // Report document variable
string reportfile = ConfigurationManager.AppSettings["CrystalReportFilePath"].ToString() + "\\" + crystalReportName + ".rpt";
try
{
DataTable report = new Datatable(); // You should put your data here
crdocument.Load(reportfile);// Load the report being displayed
crdocument.Database.Tables[0].SetDataSource(report);
}
catch (Exception exception)
{
throw exception;
}
return crdocument;
}
精彩评论