Example of basic usage in the webform of the crystal report asp.net, and the crystal report webform

Source: Internet
Author: User

Example of basic usage in the webform of the crystal report asp.net, and the crystal report webform

This article describes the basic usage of the Crystal Report asp.net webform. Share it with you for your reference.

The specific implementation method is as follows:

Copy codeThe Code is as follows: protected void Page_Init (object sender, EventArgs e)
{
ConfigureCrystalReport ();
}
Protected void Page_Unload (object sender, EventArgs e)
{
If (rptDocument = null)
Return;
RptDocument. Close ();
RptDocument. Dispose ();
}

Private void ConfigureCrystalReport ()
{
String temp = BusinessObject. Util. Decrypt (Request. QueryString ["toid"]);
TourOrderId = Util. convertize <int> (temp, 0 );

If (ViewState ["reportdoc"] = null)
{
String report_path = "";
Report_path = Server. MapPath ("~ /Report/TourNote. rpt ");

DataSet ds = BusinessObject. TourOrders. GetTourNoteDsRpt (TourOrderId );
If (ViewState ["reportdata"] = null)
{
ViewState ["reportdata"] = ds;
}
Else
{
Ds = (DataSet) ViewState ["reportdata"];
}
RptDocument = new ReportDocument ();
RptDocument. Load (report_path );
RptDocument. SetDataSource (ds );
RptDocument. PrintOptions. PaperSize = CrystalDecisions. Shared. PaperSize. DefaultPaperSize;
ViewState ["reportdoc"] = rptDocument;
}
Else
{
RptDocument = (ReportDocument) ViewState ["reportdoc"];
}

This. CrystalReportViewer1.ReportSource = rptDocument;
This. CrystalReportViewer1.HasToggleGroupTreeButton = false;
This. CrystalReportViewer1.DisplayGroupTree = false;
}

First, a dataset is created as the data source and used as the data architecture of the crystal report.

The Code calls a stored procedure and returns the DataSet with multiple tables.

I hope this article will help you design your asp.net program.


How to use Crystal Reports in ASPNET? Example

Crystal Reports can be obtained in many ways, one of which is created using vs.net. It provides a rich set of models so that we can operate on attributes and methods at runtime. If you are using vs.net to develop a. net program, you do not need to install other software because it is already embedded in vs.net. The following method can be used to retrieve data from the Execution Mode Crystal Report: pull Mode: when a request is made, the crystal report directly connects to the database based on the specified driver and then assembles the data. Push mode: At this time, the development table has to write code to connect data and assemble dataset, and send it to the report. In this case, you can use the report to maximize performance by sharing connections and limiting the size of record sets. Report Type: the crystal report designer can directly include reports to projects and use independent report objects. Stronugly-typed report: when you add a report file to a project, it becomes a "stronugly-typed" report. In these cases, you will have the right to directly create report objects, which will reduce some code and provide some performance. Un-typed report: the report is called 'un-typed 'report because it is not directly included in the project. In this case, you have to use the 'reportdocumi' object of the crystal report to create an instance and use the report manually. Other considerations although the Crystal Report viewer has some cool functions, such as scaling and page navigation. However, it does not provide the printing function. You have to call the printing function of the browser. If the Crystal Report in vs.net is not registered, it can only be used for 30 times. After 30 times, the "save" function will no longer be used. To avoid this, you are not registering this product at www.crystaldecisions.com. (It seems that this is not the case. It may take a long time if you do not register it, but you cannot provide support.) by default, the installed crystal report supports only five users. To support more users, you have to purchase a license at www.crystaldecisions.com. Let's take a look. Using a ready-made crystal report file in asp.net allows us to feel the feeling of using a crystal report in webform. 1) drag the crystal report viewer control from the webform toolbar to the. aspx page. 2) display the Properties window of the Crystal Report viewer control. 3) Click [...] to view the "data binding" attribute. The databinding window is displayed. 4) Select "report source" from the "bindable attributes" area on the left. 5) Select the "custom binding expression" radio button and specify it in the window at the bottom of the right. rpt file name and path, for example: "c: \ program files \ microsoft visual studio.net \ crystal reports \ samples \ reports \ general business \ & #9 ...... remaining full text>

C # how to do a manual CRYSTAL REPORT

Use Crystal Reports (on) in Asp. Net)

Before we studied Crystal Reports in VS. Net, my friends and I were very curious about how to add this complicated stuff to our Web application. A week later, after reading a large number of "HOWTO" documents, we successfully added some simple reports to our Asp.net program and got some tips.

This article teaches you how to use Crystal Reports in. Net Web applications, and also helps you avoid detours during your learning process. To get the best results, you 'd better have some basic Asp. Net database access knowledge and development experience using VS. Net.

Introduction

Crystal Reports can be obtained in many ways, one of which is created using VS. Net. It provides a rich set of models so that we can operate on attributes and methods at runtime. If you are using VS. Net to develop a. Net program, you do not need to install other software because it is already embedded in VS. Net.

Advantages:

VS. Net Crystal Reports have the following main advantages:

Quick report development

Ability to export complex interactive charts

It can be used with other controls in WebForm.

Reports can be imported into multiple formats, such as. txt, xls, html, and rtf.

Structure:

Some components form a layer-2 structure of the crystal report. The following Web applications are required:

Client:

The client only needs a browser that can access the reports embedded in the aspx page.

Server:

Crystal Report Engine (CREngine. dll ))

It can be used to complete some tasks, such as merging data in the report file and converting the report to another format. It is precisely because of the role of the Report Engine that the crystal report in Asp. Net can be converted into a common HTML format.

Crystal Report Designer (CRDesigner. dll ))

The crystal report is created in the designer. In the designer, you can design titles, insert data, formulas, charts, subreports, and so on.

. Rpt report file

The first step in executing the report is to create the Report on the interface of the Crystal Report designer. By default, Microsoft has provided some ready-made. rpt examples.

Data Source

. The method for getting the database from the rpt file depends on your method selection. You can choose to let the Crystal Report select data without using any code or manually assemble the DataSet, and then transfer it to the report file.

Crystal Report Viewer web form Control (CRWebFormViewer. dll ))

The crystal report display control is a WebForm control that can be viewed as a container for storing reports on the. aspx page. Note: In some complex operations, the Report Server and the Web server may not be on the same physical host, and the Web server sends HTTP requests to the Report Server. Crystal Reports can also be executed as WebServices.

Execution Mode

The following method can be used to retrieve data from a crystal report:

Pull Mode:

When a request is sent, the crystal report directly connects to the database based on the specified driver and then assembles the data.

Push mode:

At this time, the development table has to write code to connect data and assemble DataSet, and send it to the report. In this case, you can use the report to maximize performance by sharing connections and limiting the size of record sets.

Report Type:

The crystal report designer can directly include reports to projects and use independent report objects.

Stronugly-typed report:

When you add a report file to the project... the remaining full text>

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.