Solved

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

Posted on 2012-04-09
4
731 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
Comment Utility
Are you sure you are using the new report from the application?

mlmcc
0
 

Author Comment

by:shahjagat
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now