Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 910
Mehmet Avatar asked Mar 19 '12 13:03

Mehmet


People also ask

How do I create a group in Rdlc report?

To open the Report Builder, select “Layout” From the “View” menu. Provide the fields in the dataset in a table by right-clicking ->insert -> table. To create a group, on the left side of the screen, right-click and choose Add Group ->Row Group ->Parent Group. Choose the required option for grouping.


2 Answers

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")
like image 151
David Avatar answered Nov 15 '22 04:11

David


Right Click on your Report property then go to code then paste the code below

   Dim private count as integer = 0
   Dim private iniRow as integer = 0
   Dim private iniGrp as Object = ""
   Public function MatrixRow(Byval rowNum as integer,Byval rowGrp as Object) as integer

   if iniGrp = "" then
      iniGrp = rowGrp 
   end if

  if rowGrp <> iniGrp then
      iniRow = 0 
      count = 0 
      iniGrp = rowGrp 
  end if

  if iniRow = 0 then
      iniRow = rowNum
  end if

  if rowNum = iniRow then
     count = 0
  end if

   count = count + 1
   Return count
  End function

then use this function like

   =Code.MatrixRow(RowNumber(Nothing),(YourgroupfiledNameFromDataest))
like image 21
Gin Uchiha Avatar answered Nov 15 '22 04:11

Gin Uchiha