Solved

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

Posted on 2012-04-09
4
749 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
[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
4 Comments
 
LVL 101

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 35

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 101

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

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

615 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