Solved

Dynamically 'Group By' in crystal Reports ( ASP.NET/VS2008)

Posted on 2012-04-09
4
742 Views
Last Modified: 2012-04-11
I have created a group on the crystal report. Code works with one group on the report.

        objRptDoc.DataDefinition.Groups.Item(0).ConditionField = objRptDoc.Database.Tables(0).Fields(rblGroupBy.SelectedValue)
   
Now I added another group on the report and need to dynamically assign the field to the second group. Below code doesnt work with the 2nd group. It just groups by the fields that I assigned during the design time.

objRptDoc.DataDefinition.Groups.Item(1).ConditionField = objRptDoc.Database.Tables(0).Fields(rblSubGroupBy.SelectedValue)    

I'm I missing something.
Appreciate your help!!
0
Comment
Question by:shahjagat
  • 2
4 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 37824247
Are you sure you are using the new report from the application?

mlmcc
0
 

Author Comment

by:shahjagat
ID: 37824318
I'm not sure when u say 'New Report'.
I just created a report with with 2 groups assigned to two fields at design time.
0
 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 37826344
I don't know anything about running reports from code, but if you can't get the group change to work that way, maybe you could change the report to group on a formula that's controlled by a parameter, and pass different values to the parameter.  Something like this:

// Group by name or city, depending on ?param
if {?param} = "Name" then
  {name field}
else
  {city field}


 James
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37827243
You indicated this works if there is one group on the report and then yu added a second group.

If you have a standalone report and saved it, the code may still be using the version with 1 parameter rather than the updated version.If you designed this in the VS IDE then you most likely are using the correct version of the  report.

mlmcc
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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