水晶报表asp.net的webform下基本用法实例
本文实例讲述了水晶报表asp.net的webform下基本用法。分享给大家供大家参考。
具体实现方法如下:
{
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;
}
使用方法.先建了一个数据集做为数据源,作为水晶报表的数据架构.
代码里面调用一个存储过程,返回拥有多张表的dataset.
希望本文所述对大家的asp.net程序设计有所帮助。