If a report needs to be grouped by a first, then grouped by B, and then grouped by c... this multi-condition grouping makes rdlc reports not easy to process.
You can only find a different path and think about some tricks:
For example, an employee table contains the company code companycode, Department number deptno, employee number empno, and employee name empname.
You need to group the reports by company, and group the reports by Department for the same company.
Take a look at the processing belowCode
Datatable dt = new datatable (); DT. columns. add ("empno", typeof (string); DT. columns. add ("empname", typeof (string); DT. columns. add ("deptno", typeof (string); DT. columns. add ("companycode", typeof (string); DT. columns. add ("companycode_title", typeof (string); DT. columns. add ("deptno_title", typeof (string); DT. rows. add ("001", "Huo Qingtong", "A", "infosky", "", ""); DT. rows. add ("002", "fengjiu", "B", "infosky", "", ""); DT. rows. add ("003", "Cheng Ying", "C", "gsatest", "", ""); DT. rows. add ("000", "Li Xiaozhi", "A", "infosky", "", ""); DT. defaultview. sort = "companycode DESC, deptno ASC, empno"; dt = DT. defaultview. totable (); For (INT I = 0; I <DT. rows. count; I ++) {var r = DT. rows [I]; if (I = 0) {# region // The first line of special processing R ["companycode_title"] = R ["companycode"]; R ["deptno_title"] = R ["deptno"]; # endregion continue;} var r_pre = DT. rows [I-1]; # region // process companycode if (R ["companycode"]. tostring () = r_pre ["companycode"]. tostring () {R ["companycode_title"] = string. empty;} else {R ["companycode_title"] = R ["companycode"];} # endregion # region // process deptno if (R ["deptno"]. tostring () = r_pre ["deptno"]. tostring () {R ["deptno_title"] = string. empty;} else {R ["deptno_title"] = R ["deptno"];} # endregion} // print the output foreach (datarow R in DT. rows) {console. write ("{0} \ t {1} \ t {2} \ t {3} \ n", R ["companycode_title"], R ["deptno_title"], R ["empno"], R ["empname"]);} console. read ();
Use the ConsoleProgramSimulate the report output and finally print the result:
The principle is: Only one datatable is displayed row by row, but some column values in the row are "Erased" when a group is encountered ".