Reports in rdlc format and mvcrdlc format are used in MVC.

Source: Internet
Author: User

Reports in rdlc format and mvcrdlc format are used in MVC.
Preface

Recently, in the company's projects, the report module needs to use reports in the rdlc format. This report needs to be loaded using WebForm, but now ASP. NET is basically used as a project in MVC. Because it has not been used before, it is recorded for future reference.

The following is a simple Demo using VS2012 + SQL Server2012.

I. Prepare a database

I created a very simple table and added some data. Structure:

2. Create an RDLC report in the Application

2. Select "table" on the left and drag it to the right. Or right-click on the right and Choose Insert> table. The result is as follows:

3. Place the cursor over the table and click the arrow shown in the figure. The menu "Create a new data source" appears ".

4. The following page is displayed. Click Create, configure the data source, and click Save.

5. Click the arrow in step 3 to display the columns in the Table. Select the columns to be displayed in the table. The final result is as follows:

3. Create An aspx page in the Application

In the application, create a ReportPage folder and add a webForm form. Drag two widgets on the page:

 

Simply set ReportViewer and insert the node "LocalReport" in the middle of ReportView. The final webForm page is as follows:

Next, write the background code to obtain the table data source from the database.

4. Load the WebForm page in the view

At the beginning, I encountered a problem. How can I load the webForm page in the view?

Here I use iframe to direct its src attribute to the aspx page.

The main code of the View Interface is as follows:

V. Implementation results

In IE browser, an error occurs:

Follow the prompts to add the statement to web. config. Run again.

However, when the website runs in Chrome, no error is reported, but the table has no data:

In this case, you only need to set the "SizeToReportContent" attribute of the ReportViewer control to "true" on the WebForm page.

Browsing again.

Vi. Conclusion

This sharing ends now. If this article is helpful to you, please comment or recommend it!

Project Source: https://github.com/liuyang-1990/ReportDemo

Author: NaYoung
Source: http://www.cnblogs.com/liuyoung/p/7728773.html
You are welcome to repost it, but you must keep the complete article for any repost. The original Article and the original article link are displayed in the prominent area. If you have any questions or authorization negotiation, please leave a message for me

 

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.