Solved

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

Posted on 2012-04-09
4
747 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 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 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 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Analyze Shared Variable? 7 44
Consume a webservice via VB in Visual Studio 2015 3 47
Need to Interpret Json in Vb.net ( .net 3.5  framework) 11 52
Convert a string to date 4 40
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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