RDLC report series (1) Simple Dynamic Data Binding and configuration, and rdlc Dynamic Data

Source: Internet
Author: User

RDLC report series (1) Simple Dynamic Data Binding and configuration, and rdlc Dynamic Data

Recently, I changed my work and finally moved from development to primary O & M and occasional development, but it has not changed. I was looking for a job to change my career. After all, IT is really hard to say in the future in the third-tier cities. Recently, the manager gave the finance a report Presentation System. Since we have always been B2C websites, we have hardly touched on processes and reports. You can only search for materials from the blog site and csdn. Because most people use Crystal Reports, there is little RDLC information. So after a long time, I tried it myself for a long time. Finally, the project in the first phase of the project was almost done. Today, I am resting at home, so I will take some time to sort it out. This project is divided into two phases. The first phase is mainly the presentation of data tables. The second phase will be the use of matrices, line charts, and bar charts. Therefore, the article will first sort out what you have used. The Reference Links are as follows:

Http://www.cnblogs.com/waxdoll/archive/2006/02/25/337713.html wax Man Zhang (presumably do RDLC have seen)

Http://www.gotreportviewer.com/GotReportViewer (a lot of functionality is based on the instance above it)

Next, let's take a simple example by following my steps.

1. Create a project. Don't worry about it. Just name it according to your habits. Here I am demo1.

  

2. Create a new data source, right-click the website or project, choose add> new item> DATA> dataset, name it demo1.xsd, and click OK.

  

3. Drag the Abel on the Data Source Page and design the table structure.

  

4. Create a report, right-click a website or project, add a report, and name it demo1.rdlc. Click OK.

  

5. the following is a major event: design a report. Select a table from the report items on the left and drag it to the white area on the right. The following dialog box is displayed. Enter a name to select the data source and dataset, click OK and add the fields to be displayed to the table.

  

  

6. Create a page named demo1.aspx. Drag the ScriptManager and Reportview controls into the page design.

  

7. Then begin to write the code for binding data to the background, as shown below:

Demo. aspx. cs

  

1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. web; 5 using System. web. UI; 6 using System. web. UI. webControls; 7 using System. data; 8 using System. data. sqlClient; 9 using Microsoft. reporting. webForms; 10 11 namespace rdlc112 {13 public partial class demo11: System. web. UI. page14 {15 protected void Page_Load (object sender, EventArgs e) 16 {17 if (IsPostBack = false) 18 {19 FillDataToReport (); 20} 21} 22 23 private void FillDataToReport () 24 {25 26 // DataTable dt1 = GetDataTabel (); 27 28 // if (dt1.Rows. count> 0) 29 // {30 31 //} 32 33 DataTable dt = new DataTable (); 34 dt. columns. add ("Dept", typeof (string); 35 dt. columns. add ("CostCenter", typeof (string); 36 dt. columns. add ("SalePrice", typeof (decimal); 37 dt. rows. add ("IT", "810", 867); 38 dt. rows. add ("IT", "811", 877); 39 dt. rows. add ("E", "710", 867); 40 dt. rows. add ("E", "711", 877); 41 dt. rows. add ("L", "710", 867); 42 dt. rows. add ("L", "711", 877); 43 44 45 ReportViewer1.LocalReport. reportPath = "demo1.rdlc"; 46 47 // display Report 48 ReportViewer1.LocalReport. dataSources. clear (); 49 ReportViewer1.LocalReport. dataSources. add (new ReportDataSource ("dtDemo", dt); // you must specify the same name as the report. Here, dtDemo50 ReportViewer1.LocalReport is used. refresh (); 51 52 53} 54 55} 56}View Code

8. Everything seems to be finished. Run F5 and the following error is displayed. It's like a blue sky, don't worry, just configure web. config

  

9. Add the httphandler node to the web. config file. The following is my web. config file.

  

<? Xml version = "1.0"?> <! -- For more information about how to configure ASP. NET applications, visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <Configuration> <system. web> 10. Run F5. It can be a bird ,.

  

11. I will sort out some of them today, and I will take the time to present them to you later. Mainly group rows and total rows


How to bind the data in the List set to the rdlc report,

This. reportViewer1.ProcessingMode = Microsoft. reporting. winForms. processingMode. local; // reportViewer1 is the namethis of your report control. reportViewer1.LocalReport. reportPath = "ReportXml/TFirstReport. rdlc "; // the path of your rdlc report file reportViewer1.LocalReport. dataSources. add (new ReportDataSource ("DataSet1", orderList); // DataSet1 is the name of the dataset set in your rdlc report. orderList is your own data set. This. reportViewer1.RefreshReport (); In the rdlc file, you can bind the corresponding fields to the table. (Create a dataset --> insert a table --> bind data)


When aspnet makes a dynamic rdlc report, the data statistics are correct, and the display ratio of the chart is the same. The Daxia speed helps the younger brother solve the problem, as shown in figure

Are the fields bound to your graph the same?
 

Related Article

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.