This paper illustrates the basic usage of Crystal Report asp.net WebForm. Share to everyone for your reference.
The implementation methods are as follows:
Copy Code code as follows:
protected void Page_Init (object sender, EventArgs e)
{
Configurecrystalreport ();
}
protected void Page_Unload (object sender, EventArgs e)
{
if (rptdocument = null)
Return
Rptdocument.close ();
Rptdocument.dispose ();
}
private void Configurecrystalreport ()
{
String temp = BusinessObject.Util.Decrypt (request.querystring["toid"]);
Tourorderid = util.convertto<int> (temp, 0);
if (viewstate["reportdoc"] = = null)
{
String report_path = "";
Report_path = Server.MapPath ("~/report/tournote.rpt");
DataSet ds = BusinessObject.TourOrders.GetTourNoteDsRpt (Tourorderid);
if (viewstate["reportdata"] = = null)
{
viewstate["reportdata"] = ds;
}
Else
{
ds = (DataSet) viewstate["ReportData"];
}
Rptdocument = new Reportdocument ();
Rptdocument.load (Report_path);
Rptdocument.setdatasource (DS);
RptDocument.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
viewstate["Reportdoc"] = rptdocument;
}
Else
{
Rptdocument = (reportdocument) viewstate["Reportdoc"];
}
This. Crystalreportviewer1.reportsource = rptdocument;
This. Crystalreportviewer1.hastogglegrouptreebutton = false;
This. Crystalreportviewer1.displaygrouptree = false;
}
Use the method. First set up a dataset as a data source, as a crystal report data structure.
The code calls a stored procedure that returns a dataset that has more than one table.
I hope this article will help you with the ASP.net program design.