Click here to Skip to main content
15,898,134 members
Articles / SSRS
Tip/Trick

Hide/Show the row in a table in SSRS based on parameter value

Rate me:
Please Sign up or sign in to vote.
3.67/5 (2 votes)
8 Jan 2012CPOL1 min read 52.1K   2
Hide/Show the row in a table in SSRS based on parameter value

We can use SSRS (SqlServerReportingServices) to generare reports.  Once I had a requirement to generate reports to be shown based on the parameter value passed. The requirement is as below.

The report consists of taxi/train records. The Client may pass taxi or train as parameter to filter and get the record. This can be done either in database or when designing the report. If it has to be done when designing the report, let us consider the below table in the report

Assuming we have a report designed as below

HTML
    <table width="100%">
    <tr>
        <td style="background-color: #6600FF">Mode</td>
        <td class="style1">From</td>
        <td class="style1">to</td>
        <td class="style1">Timw</td>
        <td class="style1">Remarks</td>
    </tr>
    <tr>
        <td>Train</td>
        <td>Delhi</td>
        <td>mumbai</td>
        <td>10AM</td>
        <td>to be booked</td>
    </tr>
    <tr>
        <td>Taxi</td>
        <td>Marthahalli</td>
        <td>BTM</td>
        <td>9AM</td>
        <td></td>
    </tr>
    <tr>
        <td>Train</td>
        <td>Blore</td>
        <td>Chennai</td>
        <td>5PM</td>
        <td></td>
    </tr>
     <tr>
        <td>Taxi</td>
        <td>Station</td>
        <td>Home</td>
        <td>3PM</td>
        <td></td>
    </tr>
    <tr>
        <td>Train</td>
        <td>Ooty</td>
        <td>KodaiKanal</td>
        <td>3PM</td>
        <td></td>
    </tr>
</table>

The above report has 2 rows (one will show train/bus details) and the other will show taxi
details.

I will give input parameter to show all the details or only taxi details or to show only
train/bus details.

I will pass the parameter as below for variable param.

  • All
  • Train
  • Taxi


Param should be either All/Train/Taxi

Now based on the parameter value I need to display/hide the row. Right click on the row (train/bus details) -> properties -> visibility -> expression

Now give validation in expression as

VB.NET
=IIF(Parameters!Param = "All" or Parameters!Param = "Train",False,True)

By setting the above expression, the row will be made visible only when the property is
either All or Train.

For the second row, go to the visibility property and set the expression as

VB.NET
=IIF(Parameters!Param = "All" or Parameters!Param = "Taxi",False,True)

By setting the above expression, the row will be made visible only when the property is either All or Taxi

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
Developer

Comments and Discussions

 
GeneralReason for my vote of 1 Dear Pin
Member 42571371-Aug-11 0:10
Member 42571371-Aug-11 0:10 
GeneralRe: where is the reason? Pin
nainakarri8-Jan-12 22:30
nainakarri8-Jan-12 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.