Use activereport for. Net for report development (2)-bind a data source

Source: Internet
Author: User

In the previous article, I wrote a usageActivereport for. netThe simplest exampleActivereportHow to bind a data source

 

1. Create a table first Chartingtable , There are two fields, Onlineusercount , Project , Generated through the wizard Dataset And drag and drop to generate Tableadapter .

2. Next, design the display format in the report designer. Pageheader Put two Label Project and online users respectively ". In Detail Two corresponding zones Label , Respectively set Datafiled Is Project And Onlineusercount , You will see the two Label The content of the corresponding field is displayed.

3. You can specify Dataset Or Dataview As a data source, the following shows how to set a data source for a report:

UseDataset:

This. Chartingtabletableadapter. Fill (This. Dataset1.chartingtable );

Rpt. datasource =This. Dataset1;

Rpt. datamember =This. Dataset1.chartingtable. tablename;

Rpt. Run ();

This. Viewer1.document = Rpt. Document;

UseDataview:

This. Chartingtabletableadapter. Fill (This. Dataset1.chartingtable );

DataviewDV =This. Dataset1.chartingtable. defaultview ;;

Rpt. datasource = DV;

DV. rowfilter ="Project = '1 '";

Rpt. Run ();

This. Viewer1.document = Rpt. Document;

4.You can also use the report designer to specify a data source for the report.

In the report designer'sDetailThere is a small icon like a database in the header. Click it and a wizard will appear. Follow the Wizard to connect to the database step by step and define the query.

 

The preceding example shows how to bind a dataset as a data source. However, an object set is often used as a data source in a project. The next example shows how to display data in an object set in a report.

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.