繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> 报表/图形/Office >> 经典水晶报表设计—单击表头排序表格

经典水晶报表设计—单击表头排序表格

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:52  文字大小:【】【】【
简介:1. 新建一个字符串类型的参数字段,名称为 URL,用于传递 ASP.NET 程序的网址和网址的部分参数。比如:"http://www.nt.cn/cr.aspx?sort_field="。 2. 右击作为表头的文本字段,选择"设置文本格式...

1. 新建一个字符串类型的参数字段,名称为 URL,用于传递 ASP.NET 程序的网址和网址的部分参数。比如:"http://www.nt.cn/cr.aspx?sort_field="。

2. 右击作为表头的文本字段,选择"设置文本格式",进入"格式化编辑器"对话框。

3. 选择"超级链接"选项卡,并设置超级链接类型为"Internet 上的网址"。

4. 单击超级链接信息的网站地址后面的公式的钮,输入公式 {?URL} + "name"。

5. 这样表头就变成了超级链接,而且指向 http://www.nt.cn/cr.aspx?sort_field=name。

6. ASP.NET 程序在 Page_Load 事件里读取要排序的字段 sort_field,然后对水晶报表进行排序。

7. 水晶报表排序编程实例

Dim crReportDocument As ReportDocument

Public Sub changeSortField(mySortFld As String, mySortDir As String)

Dim crSortField As SortField

Dim crSortDirection As SortDirection

Dim crDatabaseFieldDefinition As DatabaseFieldDefinition

For Each crSortField In crReportDocument.DataDefinition.SortFields

If crSortField.Field.Name.ToString = mySortFld Then

crDatabaseFieldDefinition = crReportDocument.Database.Tables(0).Fields(mySortFld.ToString)

crSortField = crReportDocument.DataDefinition.SortFields(0)

crSortField.Field = crDatabaseFieldDefinition

If mySortDir = "Ascending" Then

crSortField.SortDirection = SortDirection.AscendingOrder

Else

crSortField.SortDirection = SortDirection.DescendingOrder

End If

End If

Next

CrystalReportViewer1.ReportSource = crReportDocument

End Sub

责任编辑:admin
相关文章