Hide text if empty

Stimulsoft Reports.NET discussion
Post Reply
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Hide text if empty

Post by Fabio Pagano »

I have a text with this expression:

Telephone: {MyDataSource.TelephoneNumber}

So the output is:

"Telephone: 4512328"

The field "MyDataSource.TelephoneNumber" is sometimes empty: in this case the printed text is:

"Telephone: "

I don't want to print the fixed string if {MyDataSource.TelephoneNumber} is empty. How can i do this?

Please note that i don't want to use code in report code.

Thanks.
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Hide text if empty

Post by EDV Gradl »

Clear the Text Property and add this GetValueEvent:

if (String.NullOfEmpty(MyDataSource.TelephoneNumber))
e.Value = String.Empty;
else
e.Value = "Telephone: " + MyDataSource.TelephoneNumber;
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Hide text if empty

Post by Fabio Pagano »

Thanks, but i was searching another way because i don't want to use code in report code.
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Hide text if empty

Post by EDV Gradl »

Use alread use code, because the whole report is code. Just click on the tab Code and you'll see it.

Marco
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Hide text if empty

Post by Fabio Pagano »

Autogenerated code is ok, but i don't want to add more code because i will not design the reports, my customers will design reports and they don't know nothing about how to write code.

Thanks.
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Hide text if empty

Post by EDV Gradl »

Hmm, I see, maybe you could write your own Assembly with e.g. methodShowText, which provides the hidden text, reference is in the report and then your user just had to type {ShowText("Telephone: ", MyDataSource.Telephonenumber)}


This way your user does not need to code and still get the desired result.

Marco
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Hide text if empty

Post by Guest »

You can use the IIF function in textbox:

Code: Select all

{IIF(MyDataSource.TelephoneNumber is null || MyDataSource.TelephoneNumber == "", "", "Telephone: " + MyDataSource.TelephoneNumber)}
or

Code: Select all

{IIF(MyDataSource.TelephoneNumber is null || MyDataSource.TelephoneNumber == "", "", "Telephone: ")}{MyDataSource.TelephoneNumber}
You can't solve your problem without this function, or writing code.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Hide text if empty

Post by Fabio Pagano »

"IIF" is ok. Before posting, i searched for it through intellisense in text editor, but it didn't appear. Is there another way to find it?

Thanks to all.
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Hide text if empty

Post by Guest »

You may use the StimulReport User Manual (http://www.stimulsoft.com/Documentation ... Manual.zip) to find various information about features of StimulReport.

Thank you.
Post Reply