Report Variable problem

Stimulsoft Reports.NET discussion
Post Reply
srini_morapaka
Posts: 7
Joined: Tue Feb 10, 2009 7:47 am
Location: Hyderabad, India

Report Variable problem

Post by srini_morapaka »

I have created/designed a report with two report variables (Ex. Company and Trn.Date) and these two report variables are placed on to the report. I saved the report
template in the sql server database(express). When i view the report by passing two report variables, i get correct report. But if i pass one variable (ie. Trn.Date), i am
getting the report with two variables. Trn.Date is correct, because i passed it to the report. But company is showing the value, which i had passed it at the time of report
creation. I don't want see the variable, which i did not pass to the report. Either i should delete the variable which was not passed or i should hide variable when i view the report.
It should be handled at runtime for that i have to develop logic for this. I tried to inspect the report variables in the Dictionary using StiVariable, but i am not able to delete or hide the variable.

Please provide me the sample code in c#.


thanks in advance.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Report Variable problem

Post by Edward »

Hi,

You can delete a variable from the Dictionary only in the report template before compilation, when report is just a set of objects. It is impossible to delete variable when the report has been loaded from assembly, compiled or attached as class in the Application.

The code for deleting of the Variable is simple:

report.Dictionary.Variables.Remove("VariableName");

Thank you.
srini_morapaka
Posts: 7
Joined: Tue Feb 10, 2009 7:47 am
Location: Hyderabad, India

Report Variable problem

Post by srini_morapaka »

Edward wrote:Hi,

You can delete a variable from the Dictionary only in the report template before compilation, when report is just a set of objects. It is impossible to delete variable when the report has been loaded from assembly, compiled or attached as class in the Application.

The code for deleting of the Variable is simple:

report.Dictionary.Variables.Remove("VariableName");

Thank you.
Thanks for your reply. I am able to delete the variable from the Dictionary. But, is there any solution for not to display the report variable on the report, which was not passed to the report.

Thank you.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Report Variable problem

Post by Jan »

Hello,

You want remove variables from report dictionary if it does not have value before calling report designer?

Thank you.
srini_morapaka
Posts: 7
Joined: Tue Feb 10, 2009 7:47 am
Location: Hyderabad, India

Report Variable problem

Post by srini_morapaka »

Jan wrote:Hello,

You want remove variables from report dictionary if it does not have value before calling report designer?

Thank you.
Not from report dictionary, I am able to delete variables from report dictionary. I want to delete variables from report design if it does not have value before calling report designer.


Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Report Variable problem

Post by Edward »

Hello

There is a Nullable type of variables in the Dictionary. If you do not assign such variables, their result would remain as null.
There is also a HideZeroes property in the StiText component.

If you need to modify expression or hide entire StiText component or to change somehow the expression of the report components, then you should use the following loop:

Code: Select all

StiReport report = new StiReport();
report.Load("report.mrt");
foreach (StiComponent comp in report.GetComponents())
{
    if (comp is StiText)
    {
        StiText myText = (comp as StiText);
        {

            if (myText.Text.Value.Contains("MyVariable"))
            {
                myText.Enabled = false;
            }
        }
    }
}
report.Show();
Thank you.
srini_morapaka
Posts: 7
Joined: Tue Feb 10, 2009 7:47 am
Location: Hyderabad, India

Report Variable problem

Post by srini_morapaka »

Edward wrote:Hello

There is a Nullable type of variables in the Dictionary. If you do not assign such variables, their result would remain as null.
There is also a HideZeroes property in the StiText component.

If you need to modify expression or hide entire StiText component or to change somehow the expression of the report components, then you should use the following loop:

Code: Select all

StiReport report = new StiReport();
report.Load("report.mrt");
foreach (StiComponent comp in report.GetComponents())
{
    if (comp is StiText)
    {
        StiText myText = (comp as StiText);
        {

            if (myText.Text.Value.Contains("MyVariable"))
            {
                myText.Enabled = false;
            }
        }
    }
}
report.Show();
Thank you.
Thank you very much.

it solved my problem.


Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Report Variable problem

Post by Edward »

Hi

You are welcome!

Please let us know if we could assist you any further.

Thank you.
Post Reply