| |
|

ActiveReports for .NET 2.0 Support
Started by warnestam at 04-10-2006 9:40 AM. Topic has 10 replies.
 
 
 
|
|
Sort Posts:
|
|
|
|
04-10-2006, 9:40 AM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
Sample for unbound report
|
|
|
|
|
|
Hi,
I'm currently using CrystalReports but I'm missing some basic functions. I want to create a report that is not bound to a database. Instead I want to bind it to our business layer which exports classes as List<> or ArrayList. Is this possible to do with ActiveReport, and if so is there a sample or tutorial of how it should be done?
/Robert
|
|
|
|
|
Report
|
|
|
|
04-10-2006, 10:48 AM
|
brian-dd
Joined on 11-10-2005
DataDynamics
Posts 435

|
Re: Sample for unbound report
|
|
|
|
|
You can bind ActiveReports to an object which usees the IList interface by setting the report object's .DataSource property equal to the list:
rpt.DataSource = myList;
This will bind the report at runtime.
In the report you will want to set the .DataField property of textboxes to the property they will be bound to.
Here is a link to the online help for more detail about the fields collection and binding. http://www.datadynamics.com/Help/ARNET2/ar2wlkUnboundReports.html
|
|
|
|
|
Report
|
|
|
|
04-11-2006, 9:53 AM
|
brian-dd
Joined on 11-10-2005
DataDynamics
Posts 435

|
Re: Sample for unbound report
|
|
|
|
|
What you may want to do is create a generic xml file that contains the properties of each of your business objects. Then at design time you can point the report to that xml file to have the fields list populate. Just remember to change them before you are done so they have the correct datasource.
|
|
|
|
|
Report
|
|
|
|
04-12-2006, 4:46 AM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
Re: Sample for unbound report
|
|
|
|
|
|
I've been working around a bit more and have some more question with the same topic. My business layer export data of the type List<MyClass> and I was looking at your sample (IListBindingSample) where I saw that the ActiveReport.Fields property wasn't filled - so I tried to do the same (see code at the end). My report did show data, but there where two major problem:
1) Wrong data was shown
I had set the value in the report (ActiveReports.Label.DataField) to the name of one property of MyClass. Most of the time this label show data from another property (and occasional it was the correct data).
I thought that you maybe had missed to fill the Fields property so I did it within DataInitializeEvent - that worked for all the rows expcept the first!!!
2) Data outside the frame
I'm using the web viewer control (Visual Studio 2005) to show the data in Html format. Your component generates a frame whith a specfic size, but the report goes outside this frame!
This is what I do in my web application:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // get the data List<MyClass> myData = GetDataFromBusinessLayer(); // create the report and connect it to the viewer ActiveReport report = TapReportGenerator.GenerateReport(data); webViewer1.Report = report; } }
And the project that actually creates the report
public static ActiveReport GenerateReport(List<MyClass>data) { ActiveReport report = new MyReport(data); report.DataSource = data; return report; }
|
|
|
|
|
Report
|
|
|
|
04-12-2006, 12:36 PM
|
brian-dd
Joined on 11-10-2005
DataDynamics
Posts 435

|
Re: Sample for unbound report
|
|
|
|
|
1. You will want to make sure that the controls that you are binding to the properties have the correct property name in the control's .DataField property
2. The html viewer is on a static fram, however it does have slider bars to view the report if the report is larger then the fram. You can change the viewer's size based off the report's paper size if you want the entire report desplayed.
|
|
|
|
|
Report
|
|
|
|
04-12-2006, 1:29 PM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
Re: Sample for unbound report
|
|
|
|
|
|
Thanks for the answer, but I'm not sure I understand how to solve the problem(s)
1. The values in the DataField property is double checked. But do I need to fill in the Fields property of the report?
2. I can't possible now the size of the report on a specific web client. But how do I make the frame work so the report is inside it and not floating above it?
|
|
|
|
|
Report
|
|
|
|
04-13-2006, 11:03 AM
|
brian-dd
Joined on 11-10-2005
DataDynamics
Posts 435

|
|
|
I'm curious about this constructor: new MyReport(data) Are you building the report dynamically?
You wont need to add fields to the fields collection as you are binding the report with the .DataSource property. This will bind the data to that list of objects. I've included a very simple sample.
The frame behavor seems very odd, the report is floating above the viewer? Do you have a duplicatable sample or screen shot?
|
|
|
|
|
Report
|
|
|
|
04-18-2006, 4:14 AM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
|
|
|
Thanks for the answer, that answered my original question. (I can use my business layer which export List<> objects and I don't need to fill in the Fields property of the report)
I'm sending two screenshots that shows two things (and two problems)
1) the report is outside the frame
2) corrupt data - when refreshing the page the output changes from time to time. Sometime the fields gets data from other properties.
|
|
|
|
|
Report
|
|
|
|
04-18-2006, 5:35 AM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
|
|
|
"I'm curious about this constructor: new MyReport(data) Are you building the report dynamically?"
The inparameter isn't used today. My idea is to extract more data for subreports from it. The report that I'm using are fixed and not dynamically.
By the way. The corrupt data problem seems to be fixed [update: the problem is still there, sometimes the report takes data from unknown fields] . I moved to code that created the report from the Page_Load event to WebViewer_Load event. But the "data outside frame" problem isn't solved.
/Robert
|
|
|
|
|
Report
|
|
|
|
05-02-2006, 10:25 AM
|
warnestam
Joined on 04-07-2006
Sweden
Posts 34
|
Re: Sample for unbound report
|
|
|
|
|
|
|
|
|
GrapeCity » Product Support » ActiveReports f... » Sample for unbound report
|
|
|
|
|