Click here to Skip to main content
15,880,905 members
Articles / Database Development / SQL Server
Article

Alternate Rows Coloring in SQL Reporting

Rate me:
Please Sign up or sign in to vote.
4.29/5 (7 votes)
16 Feb 20051 min read 54.7K   19   4
To change the row colors in reports.

Image 1

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.

Image 2

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.

Image 3

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

Image 4

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.

Image 5

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


Written By
Web Developer
United States United States
I'm a .Net Programmer/Web Developer, mostly working on ASP.Net C# and VB.Net,Oracle,SQL server 2000.

Comments and Discussions

 
GeneralExtenstion to Alternate Lines Pin
P. Nelson9-Jun-05 8:12
sussP. Nelson9-Jun-05 8:12 
GeneralReceiving an error Pin
kakko722-May-05 7:23
kakko722-May-05 7:23 
Generaldownload error Pin
liveboys17-Feb-05 14:34
liveboys17-Feb-05 14:34 
GeneralRe: download error Pin
Jay Kulaindevelu18-Feb-05 1:50
Jay Kulaindevelu18-Feb-05 1:50 
There is nothing to download, what are you trying to download?

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.