|
Hello, I'm sorry for asking this... I see this one is recurring, I have tried like 10 of the solutions and none seems to work.
I'm using CR for NET 2010 (installed CRforVS_13_0_1.exe)
All that I need is to pass some header parameters to a subreport that will be displayed as a common report header for all my reports. No selection or query implied, just a string to be displayed.
My process consist on calculating the dataset and then assign it to the report by code:
DataSet data = GetDS(QueryGameActivity(conn); ActivityReport Report = new ActivityReport(); Report.SetDataSource(DataSource);
1) I have created a param called "Title", both on the subreport and the main report. I have linked this parameter and I do in code:
Report.SetParameterValue("Title", "MY F TITLE!!!");
No luck, the subreport prompts for the "Title" param.
2) I have tried to use:
Report.Subreports[0].SetParameterValue("Title", "MY F TITLE!!!");
I get a runtime error, something like "Cannot be used in subreports"
3) Same error if I try:
ReportDocument subReportDocument = subr.OpenSubreport(subr.SubreportName); subReportDocument.SetParameterValue("Title", "MY F TITLE!!!");
4) I tried:
Report.SetParameterValue("Title", "MY F TITLE!!!", subr.SubreportName);
Same error
5) I have created a formula in the subreport, just to display the "Title" DisplayTitle = {?Title}
CR prompts for the "Title" parameter
6) I have created a formula in main report and link the formula to the "Title" parameter on subreport.
CR prompts again
7) I have reinstalled CR... no luck
Any other idea?
Thanks in advance
|
|
Hello again, I found and solve the problem. It's really simple. On my program I set the datasource after setting the parameter values:
//BAAAAAD!!! Report.SetParameterValue("Title", "MY F TITLE!!!"); Report.SetDataSource(DataSource);
This is incorrect. It seems that if you set the datasource, the passed parameters are wipped, so you have to set the datasource before any parameter:
//GOOOOOD!! Report.SetDataSource(DataSource);
Report.SetParameterValue("Title", "MY F TITLE!!!");
And it should work. Well, at least I did a well research on the many ways to pass parameters.
Have a good day, Eltron
|