RDLC Report Series-basic reports

Source: Internet
Author: User

I recorded a lot of issues encountered during normal development. RLDC won't be used before, but only Crystal Reports will be used, and I will be able to get started later. Record these records and use them later

1. Open VS to add a new item, select "Reporting", and select a report. The suffix is the name of RLDC.

2. add a dataset. xsd: Add a table and add a field. The field name is the same as the case of the field in the DataTable. You need to change the type of the number and date, because the number and date must be formatted in the report. if the string type is not formatted, type conversion is required.

3. Add the page and register the report namespace,

<% @ Register Assembly = "Microsoft. ReportViewer. WebForms, Version = 10.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"
Namespace = "Microsoft. Reporting. WebForms" TagPrefix = "rsweb" %>

Add

<Asp: ScriptManager ID = "ScriptManager1" runat = "server">
</Asp: ScriptManager>

Add Report

<Rsweb: ReportViewer ID = "ReportViewer1" runat = "server" Font-Names = "Verdana" Font-Size = "8pt"
InteractiveDeviceInfos = "(SET)" WaitMessageFont-Names = "Verdana" WaitMessageFont-Size = "14pt"
Height = "98%" Width = "99%">
<LocalReport ReportPath = "BS \ SalReport \ CaseRecoveryReport. rdlc"> // report path
</LocalReport>
</Rsweb: ReportViewer>

4. Add data to the report space using the post-Generation Code

Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
ReportViewer1.Visible = true;

Display ();
}
}

Void Display ()
{

ReportViewer1.Visible = true;
// Report data source
DataTable dt = new Tq_DepSale (). GetTQ_ShiftPay (fOrgNo, StartTime, EndTime, fShiftNo );
ReportViewer1.LocalReport. CES. Clear ();
ReportViewer1.LocalReport. CES. Add (new ReportDataSource ("DataSet1", dt); // This DataSet1 must have the same name as the dataset in the report.
ReportViewer1.LocalReport. Refresh ();
}

5. Design reports

Open the report file added in step 1

The control related to the report appears on the right side. Select "new dataset" to bring up the dataset window. The data name is DataSet1 by default. If the name is changed, the same name is required in the Code. Select the xsd dataset file added in step 2 for the dataset, select tables in the dataset for available data. If OK, the data field list will appear on the right.

6. Drag the table to the blank area of the Report on the toolbar, and place the data table fields on the right to the table or click an icon in the table to select the fields. After that, the table size is adjusted. Basically, the simplest report is complete. Run the query results.

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.