Bind Dataset at Runtime

Stimulsoft Reports.NET discussion
Post Reply
Dennis Ortiz
Posts: 2
Joined: Fri Jul 21, 2006 12:30 pm

Bind Dataset at Runtime

Post by Dennis Ortiz »

Hi,

I am evaluating stireport and find it a good report builder but i need to know how to bind dataset table at run time.

for example :

1. create a 1 dataset with 2 table
2. the first table contains a master data
3. the second table contains a defined schema without data
4. register dataset
5. call stireport with contain 2 databand
6. the first data band link with table 1 and databand 2 link with table 2
7. when databand complete the render for the current record i whan to fill table from diferent sources depending then content of table1 current record
8. render in data band 2 the data now containded in table2.

Note : i do these very easy in Fastreport using customs functions and call them inside Onbeforeprint event of thier quivalent of databand 1 of the example.

regards,
Dennis Ortiz


Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Bind Dataset at Runtime

Post by Vital »

You have many variants how to do this.

One of variants:

1. Add to your report third datasource (our detail datasource).
2. In DataName field please specify "Test".
3. For detail databand use reference to third datasource.
4. Create releations between master table and third table.
5. After then you need fill this table. Add following code to Report.BeginRenderEvent:

Code: Select all

//Find our master table
DataTable masterTable = this.Dictionary.DataStore[0].Data as DataTable;

//Create our detail table
DataTable table = new DataTable("Test");
table.Columns.Add("CompanyName");

//Fill our detail table. In this place you can get your details for each row.
foreach (DataRow row in masterTable.Rows)
{
	DataRow newRow = table.NewRow();
	table.Rows.Add(newRow);
}
//Bind new table to our report
RegData("Test", table);

Thanks.
Post Reply