Search code examples
rdlc

Rdlc report alignment when it filed is empty or null


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)


Solution

  • 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