Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Manipulating SortFields dynamically in Crystal Reports.Net

Posted on 2004-10-05
3
Medium Priority
?
1,236 Views
Last Modified: 2012-08-14
I am migrating my application from ASP to ASP.Net. In ASP the report sort fields could have been added dynamically (<reportobject>.RecordSortFields.Add) using the report document object model. However, I am not able to do the same using the crystalreports.net object model. All I have is ReportDocument.DataDefinition.SortFields collection which does not provide a sort method. Any idea how I can achieve this in .Net?
0
Comment
Question by:skpatra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 12242654
Here you go. This will help you
Regards
Emre

Dim crSortFields As CrystalDecisions.CrystalReports.Engine.SortFields

  Dim crSortField As CrystalDecisions.CrystalReports.Engine.SortField

  Dim crField As CrystalDecisions.CrystalReports.Engine.FieldDefinition

  Dim intCount As Integer

  Dim strTemp As String

  crSortFields = report.DataDefinition.SortFields



  'Find the Summary that I want to set the GroupSort to



  For intCount = 0 To report.DataDefinition.SummaryFields.Count - 1

     strTemp = report.DataDefinition.SummaryFields(intCount).Name

     If strTemp = "Sum ({@Room_Rev}, {GroupView.Group_Comp_Name})" Then

         crField = report.DataDefinition.SummaryFields(intCount)

         Exit For

     End If

  Next



  'Find the Group Sort and change it to the new group sort



  For Each crSortField In crSortFields

      If crSortField.Field.Name = "Group_Comp_Name" Then

          If crSortField.SortType = SortFieldType.GroupSortField Then



               'This is where the error is thrown



               crSortField.Field = crField

               crSortField.SortDirection = SortDirection.DescendingOrder

          End If

      End If

  Next



  report.SetDataSource(ViewReportsDataSet)

  ReportViewer.ReportSource = report

0
 
LVL 3

Author Comment

by:skpatra
ID: 12246257
Thanks a lot for the codeEmre. What I really want to do though is to add a new sort field (instead of updatig the field already existing). Unfortunately crSortFields does not have an Add method. Is there a workaround?
0
 
LVL 10

Accepted Solution

by:
ebolek earned 500 total points
ID: 12248071
This version doesnt let you to fo that. You have to use RDC to add a new sort field. However you can chnage the existing sort field. So hopefully that is enouhg for you. My code shows how to do that

Regards
Emre
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question