經典水晶報表設計—單擊表頭排序表格
發表時間:2024-02-26 來源:明輝站整理相關軟件相關文章人氣:
[摘要]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