Search code examples
c#winformsreportreportviewerrdlc

How can add I rownumbers for each group on a RDLC Report?


How can ı add row numbers like this:

GROUP 1

RowNumber ID Name Age

1            231     test     43
2            324     test2    45
3            354     test3    34

GROUP 2

RowNumber ID Name Age

1          657     test4    43
2          534     test5    45
3          678     test6    34

I want to do row numbers like this example.. For each group my row numbers will reset and start from 1 to groups row count.. My gruops(GROUP 1,GROUP 2, ....) are coming from db dynamically! How many group I have is not clear! here is I found some solutions but I think those solutions are available for how many groups when we know!


Solution

  • RDLCs have a RowNumber("ScopeName") Function. This will return the row number of the record within the given scope.

    You can see the existing groups for the report below the designer under a "Row Groups" and "Column Groups" headers. Select the column inside the grouping where you want the row number and view the Row Columns, The default names will be:

    [(Group1)
     ≡(Details1)
    

    Set the expression for the Row Number column to be

    =RowNumber("Group1")