I was recently styling a SQL Server Reporting Services 2005 report that contained a subreport as one of its columns. This was a tabular report that needed an alternating background color for each row. The trouble with this is that the subreport cell doesn't expose a BackgroundColor property in the report designer.

No BackgroundColor Property!
For my first attempt at fixing this, I created a parameter on the subreport called BGColor and setup the subreport's text box BackgroundColor property to get its value from the parameter.

Setting the Subreport BackgroundColor via Parameter.
This worked fine as long as the cell containing the subreport remains its original size. However my report had columns that sometimes displayed more than one line of text, which caused the row height to expand by a few lines. This expanded the cell around the subreport, but the subreport did not expand to fill this new area.

Bad Report!
At this point I decided it didn't make sense that the cell containing the subreport didn't have a BackgroundColor property. A quick search for the RDL schema showed that it's legal to have a BackgroundColor element in the Style element of a subreport element. Armed with this new information, I opened the RDL file in Notepad2 and added the following…
<Subreport Name="subreport1">
<ReportName>SubReport</ReportName>
<Style>
<BackgroundColor>=iif(RowNumber(Nothing) Mod 2, "Gray", "White")</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<ZIndex>1</ZIndex>
</Subreport>
The BackgroundColor of the subreport will now fill the entire cell even when the cell is expanded.
Note: The visual studio report designer will not display the background color. You'll need to deploy the report to an actual Report Server to see the full background color.

Good Report!

