How can I change (in design) conditionally the text of a header?

Stimulsoft Reports.WEB discussion
Post Reply
claveweb
Posts: 9
Joined: Thu Mar 19, 2009 6:49 am
Location: Spain

How can I change (in design) conditionally the text of a header?

Post by claveweb »

For example:
need to conditionally change the header of a report.
A code sample would be

IF Parameter.Value =0 THEN
Header.text='ALL'
Else
Header.text={FuenteDeDatos1.DescripcionFamilia}
END

Header.text is the value we want to show in report header
Parameter.Value is a parameter of report.
{FuenteDeDatos1.DescripcionFamilia} is a field of dataset of report (is the same throughout the report, it does no change)

Thanks for the help
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

How can I change (in design) conditionally the text of a header?

Post by Jan »

Hello,

You can use following expression:

Code: Select all

{IIF(Parameter.Value = 0, "ALL", FuenteDeDatos1.DescripcionFamilia}
Thank you.
claveweb
Posts: 9
Joined: Thu Mar 19, 2009 6:49 am
Location: Spain

How can I change (in design) conditionally the text of a header?

Post by claveweb »

Thank's but...

If i use a textbox and write this expression:
{IIF(FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 0, "ALL", FuenteDeDatos1.DescripcionFamilia)}

I get the following errors messages:
c:\users\preguera\AppDAta\Local\Temp\bspildwl.0.cs(95,40): error CS1502: La mejor coincidencia de método sobrecargado para 'Stimulsoft.Report.StiReport.IIF(bool, object,object)' tiene algunos argumentos no válidos
c:\users\preguera\AppDAta\Local\Temp\bspildwl.0.cs(95,44): error CS1503: Argumento '1': nos epuede convertir de 'object' a 'bool'

Notes:
FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue is defined as 'int'
FuenteDeDatos1.DescripcionFamilia is defined as 'sring'
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

How can I change (in design) conditionally the text of a header?

Post by Jan »

Hello,

You need use following expression if your script language is C#:

Code: Select all

{IIF(FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue== 0, "ALL", FuenteDeDatos1.DescripcionFamilia)}
Thank you.
claveweb
Posts: 9
Joined: Thu Mar 19, 2009 6:49 am
Location: Spain

How can I change (in design) conditionally the text of a header?

Post by claveweb »

The error persist.
Now the error is:
"c:\Users\preguera\AppData\Local\Temp\56ht_zhw.0.cs(95,44): error CS0019: El operador '==' no se puede aplicar a operandos del tipo 'object' y 'int'


The language I use is VB.net. However the sample code I provide is valid for simple assignments, but can be implemented as code more complex way?
"
dim a as integer
IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 0 THEN
varA=FuenteDeDatos1.Price * FuenteDeDatos.Rate1
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 1 THEN
varA=FuenteDeDatos1.Price * FuenteDeDatos.Rate1 - FuenteDeDatos1.Price * FuenteDeDatos.Discount1 /100
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 2 THEN
varA=FuenteDeDatos1.Price2 * FuenteDeDatos.Rate1 - FuenteDeDatos1.Price2 * FuenteDeDatos.Discount2 /100
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 1 OR FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 2 THEN
varA=varA + FuenteDeDatos1.Supplement
END IF

Texto.text= varA
"

How to implement all the code?
How I attach the result of this variable (in this example "varA") to the text of the report?


Thanks again and best regards
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

How can I change (in design) conditionally the text of a header?

Post by Jan »

Hello,
The error persist.
Now the error is:
"c:\Users\preguera\AppData\Local\Temp\56ht_zhw.0.cs(95,44): error CS0019: El operador '==' no se puede aplicar a operandos del tipo 'object' y 'int'
You need convert ParameterValue to int type. For example:

Code: Select all

{IIF((int)FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue)= 0, "ALL", FuenteDeDatos1.DescripcionFamilia)}
The language I use is VB.net. However the sample code I provide is valid for simple assignments, but can be implemented as code more complex way?
"
dim a as integer
IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 0 THEN
varA=FuenteDeDatos1.Price * FuenteDeDatos.Rate1
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 1 THEN
varA=FuenteDeDatos1.Price * FuenteDeDatos.Rate1 - FuenteDeDatos1.Price * FuenteDeDatos.Discount1 /100
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 2 THEN
varA=FuenteDeDatos1.Price2 * FuenteDeDatos.Rate1 - FuenteDeDatos1.Price2 * FuenteDeDatos.Discount2 /100
END IF

IF FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 1 OR FuenteDeDatos1.Parameters["@vIdFamilia"].ParameterValue= 2 THEN
varA=varA + FuenteDeDatos1.Supplement
END IF

Texto.text= varA
"

How to implement all the code?
How I attach the result of this variable (in this example "varA") to the text of the report?
You can use GetValue event of component. For example:

Code: Select all

IF Condition THEN e.Value = "STR1"
END IF

Thank you.
Attachments
214.Sample.png
214.Sample.png (88.41 KiB) Viewed 4677 times
Post Reply