Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rdlc report alignment when it filed is empty or null

Tags:

rdlc

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)

like image 242
Thiyagarajan Avatar asked Dec 11 '12 09:12

Thiyagarajan


2 Answers

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
like image 76
Gianni B. Avatar answered Oct 03 '22 08:10

Gianni B.


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à!

like image 26
Ramon Araujo Avatar answered Oct 03 '22 09:10

Ramon Araujo