How to Show the Serial Number in Reports Automatically Using Expression in .NET

This article explains how to show the Serial Number in reports automatically using expressions in .NET.


Using expressions you can add Serial Numbers to reports automatically. I will show you a demo by which you can create the serial numbers in reports.

Note: I am assuming that you can create the report. If you are a beginner to reports then follow my earlier article "Getting Started with Reports in .NET".

Use the following procedure to understand this article.

Step 1: I will create a table named "Employee" in my database "Test"

CREATE TABLE [dbo].[Employee](


[Name] [varchar](50) NULL,

[Salary] [int] NULL



insert into Employee (Name,Salary)values('A',50000)

insert into Employee (Name,Salary)values('B',10000)

insert into Employee (Name,Salary)values('C',60000)

insert into Employee (Name,Salary)values('D',20000)

insert into Employee (Name,Salary)values('E',10000)

insert into Employee (Name,Salary)values('F',70000)

insert into Employee (Name,Salary)values('G',40000)


select * from employee


Step 2: Create a page named "Default.aspx" with "ScriptManager" from the Ajax Extensions section, "SQLDataSource" from the Data section and "ReportViewer" Control from the Reporting section.

Bind the table columns with "SQLDataSource" to access the data.


Step 3: Add a report named "Report.rdlc" and bind the dataset into the reports using Table.
reports using Table

Run the "Default.aspx" after adding the report named "Report.rdlc" to the "ReportViewer" control

Purpose: I want to add the sequence number or serial number to every row.


To do this I will use an expression named "RowNumber".
  1. Insert a new column on the left side and name it "Serial No."

    Insert a new column

  2. Create the expression by right-clicking on that column as in the following:


  3. Select the "Miscellaneous" as a category and "RowNumber" as an item, then expression will be like:



    Where the nothing keyword indicates that the function will begin counting at the first row in the outermost data region. Click the "OK" button.

  4. Run the "Default.aspx" page.