External DataTable to Report.
Hi guys, this is my first topic.
I started to develop in FastReport.Net yesterday... and I'm having lots of problems...
I'm using VS2008 and C#.
1) I have in my WebForm one DataTable, how can I connect this data to the Report?
2) To design my report, how can I localize my DataTable (at DataSources area) to drag and drop the fields to the Data Band of the Report?
Any example is welcome.
Tks!
I started to develop in FastReport.Net yesterday... and I'm having lots of problems...
I'm using VS2008 and C#.
1) I have in my WebForm one DataTable, how can I connect this data to the Report?
2) To design my report, how can I localize my DataTable (at DataSources area) to drag and drop the fields to the Data Band of the Report?
Any example is welcome.
Tks!
Comments
My DataSource Window Select shows nothing. (picture attached)
WebReport component is designed to use datasources such as SqlDataSource, AccessDataSource, ObjectDataSource and similar. You can read about this in the programmer's manual, "Working with ASP.NET/Using the WebReport component". Using the DataTable component is a bit tricky. Since you don't have access to it at design time, you cannot use it as a datasource when creating a report. You may do the following:
- put the WebReport component on the form;
- invoke the report designer;
- add a new datasource using the "Data|Add Data Source..." menu. Connect to your DB and choose the table which you want in your report;
- design your report;
- now, to replace the datasource in a report with your DataTable, create the WebReport.StartReport event handler:
WebReport1.Report.RegisterData(myDataTable, "Name_of_the_report_datasource");
Your DataTable must have the same structure as the table used in a report.
I understood the way to do with DataTable but for my team it's a
little bit unproductive to work like this.
My data isn't in the database, it's at the WebSite Session.
To clarify better, it's a small cadastre with 5 fields and I don't need
to save this, just print.
I'll try to do this by the ObjectDataSource.
I'll keep in touching.
Tks.
I did the report using ObjectDataSource and it worked. (Source attached)
I have two more doubts:
1??) Can I delimit the Data Band to print just 5 records per page?
2??) How the component WebReport knows wich report (*.frx) to load? Where I set this?
I have just one report and works, but if I have two or more?
- click the data band;
- go to the Properties window;
- click Events button;
- create AfterPrint event handler:
2) By default, the report is stored in a webform. Read about storage in the programmer's manual "Working with ASP.NET/Storing and loading a report". The recommended way is to store the report in a file (via the ReportFile property). You may set this property in the Page.Load event handler to show the needed report.
I'll do more tests.
In my solution I have two pages, one to set data and another to report viewer, but I want to export the report directly do PDF without the viewer. Is it Possible?
You may use the following code:
In this case, you don't need WebReport component.