Print Page | Close Window

how to show report head data from DataTable

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=11614
Printed Date: 04 May 2025 at 12:24am


Topic: how to show report head data from DataTable
Posted By: crystaliao
Subject: how to show report head data from DataTable
Date Posted: 07 Nov 2010 at 7:17pm
I got a DataTable for resource, the column COMPANY_NAME only have NULL or certain company name, two kinds of data.

the company name will put on report header, but it's more than one row in my DataTable, so I have problem how to show the data on header?

any help will be appreciated!
thank you.



Replies:
Posted By: lockwelle
Date Posted: 08 Nov 2010 at 7:03am
don't think you can do it.  CR only reads 1 row at a time and reports on it.  If it is a group header, it looks at the first row that starts the group, and the last one for a footer...it won't read multiple rows for a header or a footer.
 
You could create a subreport that will load a shared variable that is the concatenated value you are seeking, or you can modify how you are retrieving the data to concatenate the multi row value into 1 column for the report to display.
 
HTH


Posted By: crystaliao
Date Posted: 08 Nov 2010 at 3:33pm
I got a way to solve my problem from my colleague.

I use a parameter named COMPANY_NAME then run a for loop to get a data I want and then set value to the parameter.

hope it gives help to other people too :)

String company_name = "";
for (int i = 0; i < dtObj.Rows.Count; i++)
               {
                    if (!(dtObj.Rows["COMPANY_NAME"] is DBNull))
                    {
                        company_name = (string) (dtObj.Rows["COMPANY_NAME"]);
                        break;
                    }
               }

oRptDoc.SetParameterValue("COMPANY_NAME", company_name);



Print Page | Close Window