声讨-------“经典水晶报表设计——单击表头排序表格”这篇文章
这篇文章是海波 发表于 @ 2003年12月25日 10:26:00
距今快5年了,当年海波写完,可能他那儿好用,可是他没有说明白,或许是我的水平不够,我没有做成功,5年的时间,迄今没有任何人写关于这方面的东西,承认我是一个菜鸟!!,无论在百度还是谷歌搜索,全是这篇文章,全是这篇文章,全是这篇文章,包括很多门户网站,试问有没有人做成功?!
转之前有没有问问自己:我转了,能不能用上?能不能为需要者提供方便?技术这类的东西,如果是用不上,只是转载来转载去,很没有意思,会误人子弟,何必呢?
在这里对阿泰表示敬仰,很尊重这位高人!
原文地址:http://blog.csdn.net/haibodotnet/archive/2003/12/25/21549.aspx
下面是具体的下文
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