Dynamically adding a subreport to a page

Stimulsoft Reports.NET discussion
prajan
Posts: 49
Joined: Tue Apr 23, 2013 1:28 pm

Re: Dynamically adding a subreport to a page

Post by prajan »

Hi,
I don't think I can use report.GetComponents() because I am not loading the report from a .mrt file.
In fact, if you look at the code in the attached page 'Default2.aspx' , you will know that the report is being dynamically 'created' in the page. In this case how do I calculate the sum of the group header band. Please let me know.
Thanks.
Attachments
Default2.aspx.cs
Dynamic Report Generation
(24.64 KiB) Downloaded 215 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamically adding a subreport to a page

Post by Alex K. »

Hello,

In this case please try use the following code:

Code: Select all

YourNameTextComponent = new StiExpression("{Totals.Sum(GroupHeaderBand1, Products.UnitPrice)}");
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 a million !
That did help a lot.
I have 2 more questions:
- How do I disable a group header band based on the value of a field in the datasource
- How to I set the color and font of a text based on its value.( i.e based on whether it is positive or negative)

Thanks.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Dynamically adding a subreport to a page

Post by Alex K. »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.
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:- How to I set the color and font of a text based on its value.( i.e based on whether it is positive or negative)
You should use conditions for changing color of the text. Please, watch next videos http://www.stimulsoft.com/en/videos?tags=conditions

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,
Like I already said, this report is getting generated dynamically, so I cannot use the designer to set the conditions.
I need to know, how we can set conditions in C# code
First condition - I want to disable a group header band depending on the value of a field in the data source
Second condition - I want to know how we can set the color and font of a text based on its value.

Please let me know if I haven't been clear.

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.

Here is a sample code how to add Conditions:

Code: Select all

            StiCondition highlightcond = new StiCondition();
            highlightcond.DataType = StiFilterDataType.Numeric;
            highlightcond.TextColor = Color.Red;
            highlightcond.Column = "Categories.CategoryID";
            highlightcond.Condition = StiFilterCondition.EqualTo;
            highlightcond.Value1 = "1";
            highlightcond.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold);
            highlightcond.BackColor = Color.Beige;
            highlightcond.Enabled = true;
            headerText.Conditions.Add(highlightcond);
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 a lot. That worked like a dream!

I have another query. I am unable to add vertical line primitives dynamically to the report using C#.
I tried as below, but the line is not seen in the report.

Code: Select all

StiVerticalLinePrimitive stiLine1 = new StiVerticalLinePrimitive();
        stiLine1.Top = 2;
        stiLine1.Height = 10;
        stiLine1.PrintOn = StiPrintOnType.AllPages;
        stiLine1.ShiftMode = StiShiftMode.IncreasingSize;
        stiLine1.Printable = true;
        stiLine1.Enabled = true;
        pnReportTitle.Components.Add(stiLine1);
In the above code, I have tried adding the vertical line to a panel.
Previously I tried adding it to a page as well as to a report title band.
In all cases the vertical line is not seen at all.

Any help would be highly appreciated.

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.

Please, try to use Borders instead of the Line Primitives.

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 need to add line primitives only. I cannot use borders.
Can you please let me know how it is possible?

Thanks
Post Reply