Fastreport for. NET Data bonding

Source: Internet
Author: User

C # Code:

PrivatevoidButton4_Click (Objectsender, EventArgs e)
{
Print master and slave table data
StringFILE = Application.startuppath @ "\masterdetail.frx";
Rptmasterdetail.load (file);To load a report template file

DataSet ds = DAL. Getmasterdetaildata ();Fetching report data

Rptmasterdetail.registerdata (ds. Tables[0], "tb_so");Registering a data source, primary table
Rptmasterdetail.registerdata (ds. Tables[1], "Tb_sos");Registering a data source from a table

//
Registering a DataSet directly is OK, but you must specify a table name for Dataset.tables!
Fastreport is a DataTable object that is followed by a table name.
//
Rptmasterdetail.registerdata (DS);
//

Bind data Source to Databand (primary table data)
Databand Masterband = Rptmasterdetail.findobject ("Data1")AsDataband;
Masterband.datasource = Rptmasterdetail.getdatasource ("Tb_so");Main Table

Bind a data source to Databand (detail data)
Databand Detailband = Rptmasterdetail.findobject ("Data2")AsDataband;
Detailband.datasource = Rptmasterdetail.getdatasource ("Tb_sos"); List

Important!! Set the primary foreign key relationship for the schedule!
Detailband.relation =NewRelation ();
DetailBand.Relation.ParentColumns =NewString[] {"SONO"};
DetailBand.Relation.ParentDataSource = Rptmasterdetail.getdatasource ("Tb_so"); Main Table
DetailBand.Relation.ChildColumns = new string[] {"SONO"};
DetailBand.Relation.ChildDataSource = Rptmasterdetail.getdatasource ("Tb_sos"); //Schedule

//Prepare to work, display report preview form
Rptmasterdetail.prepare ();
Rptmasterdetail.showprepared (True, this );

}
Specific steps:

1. Load the report template file, load ().
2. Get the report data through the DAL layer, return the dataset type, containing two data tables (main Table tb_so, Schedule Tb_sos).
3. Registerdata, register the data source. Important
4. Bind the data source to the Databand object, named Data1 bind the main table, DATA2 bind the schedule. Important
5. Set the primary foreign key relationship for the schedule Databand. Important
6. Prepare the report and display the preview form.

Fastreport for. NET Data bonding

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.