您现在的位置:网络学院 > 开发教室 > 跟我学.net
在Visual Studio.NET中使用Crystal Report(上)

出处:PConline
责任编辑:pjl

[02-4-5 16:19] 作者:cashcho/中国软件


现在让我们看看如何将一个Crystal Report文件应用于你的web form。

(1) 从tool box中拖出一个"Crystal Report Viewer"放到你的.aspx页面上。



(2) 打开这个control的属性窗口。

(3) 在"Data Binding"属性上点击[...]弹出data binding窗口。

(4) 从左边选择"Report Source"。

(5) 选择"Custom Binding Expression",在下边的表单中输入以下语句:

"C:\Program Files\Microsoft Visual Studio.NET\Crystal Reports\Samples\Reports\General Business\World Sales Report.rpt"

记得要包括引号,点OK。



注意:这个‘World Sales Report.rpt’文件是做为VS.NET的一部分被安装的。如果你指定了一个不同的路径安装VS.NET,请自行修改。

(译者注:C#用户请输入以下字符串:"C:\\Program Files\\Microsoft Visual Studio.NET\\Crystal Reports\\Samples\\Reports\\General Business\\World Sales Report.rpt")

经过短暂时间的加载后,你将会看到一个简单的预览 。

上面的步骤实际上在你的.aspx页面上插入了如下代码:

< %@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web" %>

和在< form>段里的

< CR:CrystalReportViewer

id="CrystalReportViewer1"

runat="server"

Width="350px" Height="50px"

ReportSource='<%# "C:\Program Files\Microsoft Visual Studio.NET\Crystal Reports\Samples\Reports\General Business\World Sales Report.rpt" %>'>

< /CR:CrystalReportViewer>

(6) 调用DataBind方法,在Code Behind文件中编辑Page Load Event

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

DataBind()

End Sub

(7) 保存,生成并运行。现在你已经有了一个包含Crystal Report文件的页面了。



本文转载自中国软件(http://www.csdn.net)。

[上一页]


相关文章:

用Asp.net实现基于XML的留言簿之一
用Asp.net实现基于XML的留言簿之二
用Asp.net实现基于XML的留言簿之三
用Asp.net实现基于XML的留言簿之四
使用VS.Net 做.Net组件
.NET是什么,如何影响我?


内容搜索 
高级搜索

本栏今日焦点