The lack of support for CSS style sheets in reporting services can make life difficult when you want to have common formatting across reports. There are also occasions where you may want to share common conditional formatting logic across reports. This example shows how common code can be used to help in these scenarios.
Whilst a .NET assembly would probably be more efficient not everybody is in a position to write and deploy .NET assemblies.
The first example simply sets the background color of a textbox based on the value of a variable.
In this example the textbox background is set to red if the value is less than 50 otherwise it is set to green. This logic may be required in multiple textboxes in a single report or across multiple reports.
Open your report and under properties add the following to the code
function StopGoColor(d as decimal) as string
StopGoColor = iif(d < style="font-family:arial;">end function
Select the textbox where you want apply the conditional formatting and enter the following expression for the fill color using your own value to pass to the function
This function can be used through out your report to ensure consistant formatting.
Once you have written the functions you require you can create a report template by copy the code into an empty report and saving this report into the C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject direcory.
Now when you select Add New you will get the option to base any new report on the newly created template report which already contains your common formatting code.