[Original] rdlc report series (5) rdlc Report Group

Source: Internet
Author: User

Address: http://www.cnblogs.com/jack86514/archive/2011/05/04/2036039.html

This article only represents the understanding of the author at a certain stage.

I,Prerequisites

In my blog, I wrote about the use of some rdlc reports. Please refer to here. Because there is no time, it is not imported into my personal blog. RelatedArticleAs follows:

    • [Original] rdlc report series (1) create a report
    • [Original] Insert images in rdlc report series (2)
    • [Original] use of parameters, constants, and common expressions in the rdlc report series (III)
    • [Original] use of rdlc Report Series (4) subreports

Ii. content of this article

    1. Load rdlc report data
    2. Implement Data grouping
    3. Summary
    4. CodeDownload (download)

Iii. Loading rdlc report data

In our example, We need to extract 200 student information from the student table and then load it into the rdlc report.

Using system; using system. collections; using system. configuration; using system. data; using system. LINQ; using system. web; using system. web. security; using system. web. ui; using system. web. UI. htmlcontrols; using system. web. UI. webcontrols; using system. web. UI. webcontrols. webparts; using system. data. sqlclient; using system. collections. generic; using system. XML. LINQ; using Microsoft. reporting. winforms; using rclc. dataentity; namespace rclc {public partial class _ default: custompagebase {protected void page_load (Object sender, eventargs e) {} protected void buttonreportgenerate_click (Object sender, eventargs E) {list <reportdatasource> reportdatasource = new list <reportdatasource> (); rportdataset DS = new rportdataset (); string templatepath = string. empty; string totalrecords = string. empty; // obtain the data sqlconnection conn = new sqlconnection (configurationmanager. connectionstrings ["loggingconnectionstring"]. connectionstring); sqlcommand command = Conn. createcommand (); command. commandtype = commandtype. text; command. commandtext = "select top 200 * From t_student"; sqldataadapter da = new sqldataadapter (command); DA. fill (Ds. t_student); // specify the report template templatepath = "reporttemplate/studentreport. rdlc "; // provides the obtained data set to the report named rportdataset_t_student dataset reportdatasource. add (New reportdatasource ("rportdataset_t_student", DS. t_student); List <reportparameter> parameterlist = new list <reportparameter> (); // generate report. The report can generate PDF, Excel, and other forms, set getreportmultipledatasourcefile (reportdatasource, templatepath, parameterlist, "pdf") as needed ");}}}
The above code has obtained information about 200 students, and then extracts the data from the database and loads the data In studentreport. rdlc Report, the following task is to group the data.

4. Grouping

Next we will group students based on their gender. The steps are as follows:

    • Open the rdlc template file, click the row label of the report, and then click Insert group )"

    • In the insert group window, select the expected grouping field (the student's gender here), as shown in

    • After inserting a group, we can add a title to the Group, with the title gender.

In this way, the group is over. Next, let's take a look at how it works.

]

You can also download the PDF results (download) from here ).

V. Summary

Through the example above, we learned how to use the rdlc grouping function to implement the function. Through the example above, we inserted a personalized group. Of course, we can also insert a sub-group into the group, to implement level 2, level 3 or level n grouping.

Of course, you can perform grouping statistics and other functions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.