Jith
Jith

Reputation: 1701

Row color and Alternate Row color for Table in RDLC Report

How do I give row color and alternate row color for a Table in RDLC report? When I googled I found most of the result says something like = iif(RowNumber(Nothing) mod 2, "Red", "White") OK! But where should I place this stuff? Any help will be appreciated.

Upvotes: 26

Views: 48616

Answers (5)

Ramon Araujo
Ramon Araujo

Reputation: 1738

If you don't want to add a RowNumber field to your dataset, just use the built in function RowNumber(ScopeName as String). I commonly use the name of the DataSet as parameter:

= IIF(RowNumber("CarsWithNoMakeDataSet") Mod 2 = 0, "LightGrey", "Transparent")

You can find this function at the Expression dialog, Category "Common Functions", Subcategory "Miscellaneous"

As the ScopeName parameter it is possible to use the name of a Group or Data Region. Please find more here.

Hope it helps,

Upvotes: 26

Jayakrishnan S
Jayakrishnan S

Reputation: 11

You can use group data region instead of dataset name.

Eg: = IIF(RowNumber("MonthOfYearId") Mod 2 = 0, "LightSteelBlue", "No Color")

Upvotes: 1

user8396332
user8396332

Reputation: 11

Note that using dynamic expression can affect the time required to export a report. For a report with 5K of rows, the time increase may reach 2-3 minutes.

This is the expression I had to remove from one of my reports to make the export time acceptable: =iif(RowNumber(Nothing) Mod 2, "White", "#e6eefc")

Upvotes: 1

codea
codea

Reputation: 1539

The expression definition to alternate the row color is:

=iif(Fields!RowNumber.Value Mod 2 = 0,"LightGrey","White")

This sample assumes you have a field RowNumber in your dataset.

Upvotes: 20

marc_s
marc_s

Reputation: 754278

Very easy! :-)

In your report designer surface, you need to select the data row that contains your data - something like this:

enter image description here

When you look at the Properties box for that data row, you will see a property call BackgroundColor - open the dropdown, and you'll see all the usual colors - but also a menu item at the bottom called Expression...:

enter image description here

When you select that item, a dialog box will open that allows you to insert an expression to determine the background color for that row - that's where you need to put that expression that you have - and that's all there is!

Upvotes: 34

Related Questions