Dynamically adding a subreport to a page

Stimulsoft Reports.NET discussion
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically adding a subreport to a page

Post by HighAley »

Hello.

There are 2 different issues in your reports.

1. The issue with redundant components.
I made some changes in your last report. Please, look at the ReportTitleBand1 and the HeaderBand1. You don't need those Panels, Data Band and GroupHeaders without conditions to build your report.
All those components make your reports hard to build and to change in future. As well your code is too complicated.
You could delete almost all other components with no effect on the final report.
BS_Horz_NoPC_modified.mrt
(110.48 KiB) Downloaded 159 times
2. The issue with Vertical Line Primitives.
At first I will repeat that if you remove all redundant components, it's will be possible to avoid using this very complicated component Line Primitives which slows down rendering of reports very much.
But nevertheless, here is a sample report where you could find out how to add just one vertical line. You could see the code on the Code tab.
VerticalLine.mrt
(5.46 KiB) Downloaded 148 times
Please, pay attention on next moments:
  • you should add 2 points: StartPointPrimitive1 and EndPointPrimitive1
  • the ReferenceToGuid property of these point should refer to Guid of VerticalLinePrimitive1
  • the Parent of StartPointPrimitive1 is HeaderBand1 and the Parent of EndPointPrimitive1 is FooterBand1.
If you miss any of this important notes the Line Primitive will not grow.

As you see it's better to use Border property of the components then to create Line Primitives in code.

Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,

PFA the 2 reports - one generated using the .mrt file you sent - 'BS report generated using the report file sent'
BS report generated using the report file sent.pdf
(12.98 KiB) Downloaded 521 times
and the other using the .mrt file created by us - 'BS report generated using our report file'
BS report generated using our report file.pdf
(15.09 KiB) Downloaded 166 times
You will see the difference in the report. It is for these differences that we have had to add certain Panels, Data Band and GroupHeaders without conditions.

Now, as per your suggestion I did try to add a StiVerticalLinePrimitive along with StiStartPointPrimitive and StiEndPointPrimitive.
Just to make sure that my 'redundant' panels and group headers are not causing the problem, I have removed all of those, but still I only see the line in the second page and not the first page. The report for the same is
BS Report with PC.pdf
(20.49 KiB) Downloaded 311 times
The code used for the same is
Default2.aspx.cs
(35.46 KiB) Downloaded 134 times
Please let me know what it is that I am missing here. I have tried so many permutations and combinations but without luck. That is the reason I took so long to reply.
Any help from your side which helps me get this report right will be highly appreciated.

Thanks in advance.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically adding a subreport to a page

Post by HighAley »

Hello.

You didn't set the Guid property:

Code: Select all

stiLine1.Guid = null;
Please, try to set Guid with next code:

Code: Select all

stiLine1.Guid = Guid.NewGuid();
Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,

I cannot give

Code: Select all

stiLine1.Guid = Guid.NewGuid();
as it gives the error "Cannot implicitly convert type 'System.Guid' to 'string'"

I tried the following code :

Code: Select all

stiLine1.Guid = Guid.NewGuid().ToString();
It didn't work. So I tried this :

Code: Select all

Guid newg = new Guid();
stiLine1.Guid = newg.ToString();

This too didn't work.
What else can I try ?


Thanks
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically adding a subreport to a page

Post by HighAley »

Hello.

We use next code:

Code: Select all

public void NewGuid()
        {
            guid = System.Guid.NewGuid().ToString().Replace("-", "");
        }
Please, try this.
Other way is to use next method:

Code: Select all

NewGuid().ToString("N")
Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,
No luck with either of the two codes :(
Any other suggestions ?

Thanks
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically adding a subreport to a page

Post by HighAley »

Hello.
prajan wrote:No luck with either of the two codes :(
Any other suggestions ?
Could you describe it more detailed?
Please, send us your current project.

Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,
PFA the project for generating the report and the data for the same.
When you run it,you can see that the the vertical line primitive ( in red colour) is only seen in the second page and not in the first page.
I want the line to be seen from the header in the first page to the footer in the last page.
Please let me know how this can be achieved.

Thanks
Attachments
Data for rep.rar
Data for the report
(4.89 KiB) Downloaded 140 times
BSReport.rar
Report project
(180.48 KiB) Downloaded 145 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamically adding a subreport to a page

Post by HighAley »

Hello.

You see such behaviour because there is no end point on the first page.
Try to add empty footer with some height and add the end point on it.

Thank you.
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,
Thanks for the reply. It did help me finally generate the report.
One last doubt.
I want to open the report as a PDF in a popup page.
I am opening the page as a pop-up and in that page I have the following code to generate the report as PDF.

Code: Select all

  
StiReport report = CreateReport2();    
report.Render(false);
StiWebViewer1.Report = report;
StiWebViewer1.ViewMode = StiWebViewMode.WholeReport;
report.IsRendered = false;
StiReportResponse.ResponseAsPdf(this.Page, report, true);
The page opens but the report is not seen.
If I run the same code in a page that is not a pop-up then the PDF report gets generated properly.
Please let me know if I am missing something.

Thanks
Post Reply