10
votes

here is my problem

I am working with Rdlc report. I have these fields:

First name  
Address1 
Address2  
City, state, zip

If any one of these fields is empty, it should not show the blank space. For example (expected output)

First name,  
Address1,  
City, state, zip  

But, as show in the above image, I am getting this:

First name,  
Address1,  
........................<-(blankspace is showing here)  
City, state, zip 

I tried changing Visiblity -> Expression -> =IIF(String.IsNullOrEmpty(Fields!Address2.Value), false,True)

3

3 Answers

17
votes

I think that the expression with String.IsNullOrEmpty didn't works.

Try with one of this two options:

1.=IIF(IsNothing(Fields!Address2.Value),False,True)

2.=IIF(Len(Fields!Address2.Value) = 0,False,True)

According to the comments, the solution is to create a single textbox in which put two (or more) fields and concatenate the value if the second fields has a real value or is empty.

So the expression will be:

=Fields!Name.Value + System.Environment.NewLine + Fields!SAddr_Line1.Value + IIF(‌​Len(Fields!Address2.Value) = 0, "", System.Environment.NewLine + Fields!Address2.Value) + Fields!ShipTo.Value

For more readability:

=Fields!Name.Value
+ System.Environment.NewLine
+ Fields!SAddr_Line1.Value
+ IIF(‌​Len(Fields!Address2.Value) = 0, "", System.Environment.NewLine + Fields!Address2.Value)
+ Fields!ShipTo.Value
1
votes

Just in case this helps somebody.

I suffered the same (and I had quite complex grouping on) until I did:

Fields!FieldName.Value * 1

(You can then convert to String using CStr() if needed)

And voilà!

0
votes

You Can Use if else statement in the following cases in rdlc report

     1=IIF(IsNothing(Fields!Amount.Value),False,True)
     2.=IIF(Len(Fields!Amount.Value) = 0,False,True)

       =iif(IsNothing(Sum(Fields!Amount.Value)),0.00,True).ToString()

last one when no records found and display 0 its working!