Bind report to DataTable

Stimulsoft Reports.WEB discussion
Post Reply
mobo10
Posts: 3
Joined: Tue Oct 18, 2011 1:35 pm

Bind report to DataTable

Post by mobo10 »

Good afternoon,

In the designer, I am setting a DataSource so that I can get the list of fields that are available in the report.

At runtime however, while I use the same fields, the SQL I use to generate the query can be one of many different combinations.

My question is, how can I use a DataTable as the datasource of the report? The code below is not working (it always returns the results of the DataSource from the designer, as opposed to the DataTable (tbl).

StiReport report = new StiReport();
report.Load("REPORTNAME");


DataTable tbl = ReportDataSource();
report.RegData(tbl);

StiWebViewer1.Report = report;
StiWebViewer1.DataBind();

Thanks!
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Bind report to DataTable

Post by Vladimir »

Hello,

Please try to use this code:
StiReport report = new StiReport();
report.Load("REPORTNAME");

report.Dictionary.Databases.Clear();

DataTable tbl = ReportDataSource();
report.RegData(tbl);
report.Render(false);

StiWebViewer1.Report = report;
Thank you.
mobo10
Posts: 3
Joined: Tue Oct 18, 2011 1:35 pm

Bind report to DataTable

Post by mobo10 »

This did not work - all pages come up blank even though the DataTable has rows. I have defined the columns and a datasource in the report designer, I don't know if that matters.

I can include the report mrt if that would help.

Thanks.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Bind report to DataTable

Post by Vladimir »

Hello,

Please send us your MRT file, and also data for it, that would reproduce the problem.
You can send your files to support[at]stimulsoft.com with the link to this topic.

Thank you.
Post Reply