Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Alternate Rows Coloring in SQL Reporting

0.00/5 (No votes)
16 Feb 2005 1  
To change the row colors in reports.

Introduction

Like every other report has some or the other way to make it look beautiful, SQL Reporting also has some good features, but here I will be just showing how to make the color change for alternate rows.

Purpose

Generally, with detailed reports, if the look is made a little good, then everyone loves it.

Using the code

There is not much coding to be done, just a single line of code will solve this issue. Get the DataSet name after you have configured the DataSet.

When you use the table in your report, the table, by default, shows three rows, the header, detail and the footer. In this section, we will delete the footer row. Select the detailed row, right click, and select Properties.

In the Properties page, select the BackgroundColor property, pull down the dropdown, and select <Expression>.

On the left pane of the Edit Expression, select Constants (which is selected by default), and in the Expression pane, type the following line and click OK:

=IIF(RowNumber("NWDataSet") Mod 2, "Gainsboro", "White")
// NWDataSet is the Dataset name.

That's it! Click the preview and you are good to go..

Points of Interest

SQL Reporting tool provides a lot of great other features, like if you have a detailed report of employees salary list and you want to highlight only rows whose salary is high, you could do it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here