當前位置:開發者網絡 >> 技術教程 >> .NET教程 >> 報表/圖形/Office >> 內容
精彩推薦
分類最新教程
分類熱點教程
    
經典水晶報表設計—單擊表頭排序表格
作者:未知
日期:2004-03-04
人氣:
投稿:Andy.m(轉貼)
來源:未知
字體:
收藏:加入瀏覽器收藏
以下正文:
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
相關文章: