This article explains how to show the Serial Number in reports automatically using expressions in .NET.
Description
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.

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.
Solution
To do this I will use an expression named "RowNumber".
- Insert a new column on the left side and name it "Serial No."

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

- Select the "Miscellaneous" as a category and "RowNumber" as an item, then expression will be like:
=RowNumber(nothing)
Where the nothing keyword indicates that the function will begin counting at the first row in the outermost data region. Click the "OK" button.
- Run the "Default.aspx" page.


ratnesh kumarPosted Feb 16, 2021, 9:58 AM
After splitting the use of exp. (=JOIN(Split(Fields!FileName.Value,"?"), System.Environment.NewLine)) splitting row into column and add serial number 1, 2, 3 so on. how to do. ?
shivaram santoshPosted Feb 19, 2018, 6:11 AM
Thanks for useful information
Shovan SahaPosted Jun 19, 2017, 1:26 PM
Serial number is essential. Thanks for sharing.
Shovan SahaPosted Jun 19, 2017, 1:25 PM
Serial number is essential. Thanks for sharing.
veera muthuPosted Jan 11, 2016, 12:33 AM
Thankyu For your useful information
Nikunj TrivediPosted Aug 18, 2015, 6:18 AM
Good One Article Sir....Its Very helpful to us.......But I have One Query Regarding Crystal Report..How to print crystal report programatically on button click ?? bcoz in Visual studio 2010 crystal report , there are so many problems on PRINT button and Export button.
Sandeep JaglanPosted Jul 30, 2015, 6:07 PM
this doesn't work well when you have row show/hide condition is enabled
majedul islamPosted Feb 16, 2015, 2:44 AM
thnx
Gm ArifPosted Jan 5, 2015, 9:15 AM
thanks
mohan ChandankarPosted Jul 5, 2014, 5:29 AM
thanx