繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 《简单实现Crystal Report动态加载》补遗

《简单实现Crystal Report动态加载》补遗

2006-05-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:在《简单实现Crystal Report动态加载》中,所提供的方法有时候并不能很好的工作。于是通过不断的实验和资料查询,终于发现了更好的方法。核心代码如下 CrystalDecisions.Web.CrystalReportViewer CrystalReportV...

在《简单实现Crystal Report动态加载》中,所提供的方法有时候并不能很好的工作。于是通过不断的实验和资料查询,终于发现了更好的方法。核心代码如下

CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

String path = Server.MapPath("./");

path = path + @"\Report\Report.rpt";

path = path.Replace("\\","\\\\");

ReportDocument Rep=new ReportDocument();

Rep.Load(path);

DataSet ds = getDataSet(getConn());

Rep.SetDataSource(ds);

CrystalReportViewer1.ReportSource = Rep;

CrystalReportViewer1.DataBind();

如上代码所示,这个方法通过ReportDocument类的Load()方法把报表模板加载入内存,利用推模式把DataSet数据推入模板。最后把这个ReportDocument绑定到CrystalReportViewer上。

责任编辑:admin
相关文章