Asp. Net + Grid Report implements Web reports and gridreport
When I was working on the VB version of the data center charging system, I think everyone was impressed by the Crystal Reports in the weekly statement. The operation process is as follows: when the form is loaded, all data in the data table is displayed in the form. Select the query condition and click the query button to filter the displayed data. If you want to print the report, click the print button on the control to print.
However, these operations are completed in the C/S structure. Recently, Langfang Personnel Bureau customers asked our development team to print the B/S report. After a day of hard thinking, I finally completed a successful Demo. I would like to share with you the results and hope to help you make progress.
The solution directory is as follows:
The procedure is as follows:
1. Import the ReportData. cs, MssqlReportData. cs, and CreateControl. js officially provided by the Grid Report. We recommend: http://pan.baidu.com/s/1qWoGe9A;
2. Use the Grid ++ Report designer to create the aaa. grf Crystal Report. For details about the process, refer to the blog: use VB for reports;
3. When page loading is completed, you need to set the SQL statement for displaying data in showAll. aspx.
<%@ Page Language="C#" %><script runat="server"> protected void Page_Load(object sender, EventArgs e) { SqlXMLReportData.GenDetailData(this, "select * from aaa"); }</script>
4. After clicking the query button, you need to set the SQL statement for data filtering in showPart. aspx.
<%@ Page Language="C#" %><script runat="server"> protected void Page_Load(object sender, EventArgs e) { string QuerySQL = string.Format("select *from aaa where account='{0}'" ,Request.QueryString["account"]); SqlXMLReportData.GenDetailData(this, QuerySQL); }</script>
5.set the aspx file for each access in displayviewreport.htm of the display page
<Html xmlns = "http://www.w3.org/1999/xhtml"> The Code shows that when an html page is loaded, the page loads aaa under the grf folder. grf file, at the same time to showAll. aspx request aaa. grf data displays the SQL statements to be executed.
After the query button is clicked, the html page uses ReportViewer. dataURL is directed to showPart. aspx submits query parameters, showPart. aspx uses Request. queryString ["account"]) receives the query parameters submitted by html, and then uses SqlXMLReportData. the GenDetailData () method executes SQL statements with query parameters.
At this point, the preparation has been completed. Let's take a look at the code running effect:
Page loading:
Click query:
How is it like C/S! If you like it, just give it a compliment. Thank you.
How to Use the Grid ++ Report designer
After downloading and installing the SDK, check the example. There are many examples in the installation directory.
Help in the "product introduction-> Quick Start Guide" section. According to the instructions in the Quick Start Guide, run the example program first.
The example of Grid ++ is divided into two parts:
1. Report Template example: describes the design of Reports in various formats. It is installed by default in the C: \ Grid ++ Report 5.0 \ Samples \ Reports directory.
2. Examples of application reports in various programming languages. corresponding examples are provided for each programming language. By default, the C/S Report is installed in the corresponding subdirectory of the C: \ Grid ++ Report 5.0 \ Samples directory, and the B/S Report is in the C: \ Grid ++ Report 5.0 \ WebSamples directory.
C # How to call the designed Report with Grid ++ Report?
C: \ Grid ++ Report 5.0 \ Samples \ CSharp
First, let's take a look at the example in this directory. It should be a few lines of code.