Link to home
Start Free TrialLog in
Avatar of townsma
townsmaFlag for Indonesia

asked on

Using IList<T> As DataSource for Crystal Reports

I am currently changing all my applications over from using DataSets to using IList<T> as created by Lightspeed ORM.

Whilst I know how to assign the IList<T> as the datasource at runtime.  I am unable to find a way to assign the class as a datasource at design time so I can set the report layout.  Has anyone done this?

I am using VS2008, Framework 3.5 with Crystal Reports 2008.
Avatar of kaylanreilor
kaylanreilor
Flag of Luxembourg image

I think this guy here (http://www.softpilar.com/knowledge-sharing/how-to-create-a-crystal-reports-invoice-and-export-it-as-pdf.aspx) is doing the same as you need. If you look to the "Fill data in the dataset and bind it to the report template" section you'll see that he has got a custom object list "IList<InvoiceLine>".
Avatar of townsma

ASKER

Thanks for the link, but this is not really what I am looking for.  A Crystal Report can bind to data in any object as long as it is based on IEnumerable, i.e. IList<T>.  In the example shown, the guy creates a Dataset, then copies the information from the IList<T> into the DataSet to pass to the report.  When actually you can pass the IList<T> directly to the report.

However, the point of my question is not how to pass the data to the report a runtime, but rather how to design the report based on the class in the IList<T>.  I have read the article on the CR  (SAP) website entitled Crystal Reports in VS2005 walkthrough, and in particular, Binding to .Net Objects.  However, I run in to some problems, maybe because using VS2008.  Firstly, and most importantly, the class created by Lightspeed does not appear in the list of .Net Objects.  

Has anyone used Lightspeed object with Crystal Reports?
Did you already go through this tutorial : http://msdn.microsoft.com/en-us/library/ms227595.aspx.
They are not using an IList<> collection but an ArrayList and the SetDataSource method of the report (http://msdn.microsoft.com/en-us/library/ms227653.aspx). Nevertheless, I understand for now that you don't absolutely need to use IList<>, do you ? And anyways, I think that doint the same with an IList<> would work as well.
Avatar of townsma

ASKER

Hi, the information there is almost identical to that on the SAP website.  However, I can't get it to work.  

The class is auto-created by Lightspeed, but is public with pubic properties etc. the same as the sample.  But when I use the Wizard in Crystal Reports, under .Net Objects, the Lightspeed classes are not available for me to select them.  I  think this is because the Lightspeed "Data" Classes are located in a separate data project, where the report file is in a UI project.

So I tried to create a new class inherited from the Lightspeed class, but when I do this, it asks me for the path to the XML file?  All very confusing.
Avatar of gokujames
gokujames

Please copy the Class generated by Lightspeed to a separate Class file & add to App_Code folder of asp.net application.Now you can add a "Object DataSource" from the Data tab of the Toolbox & configure it in such a way that ,the method of the Lightspeed generated class can be used for various purposes.
ASKER CERTIFIED SOLUTION
Avatar of townsma
townsma
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please anyone if you have used post the answer to this question...
I am currently changing all my applications over from using DataSets to using IList<T> as created by Lightspeed ORM.

Whilst I know how to assign the IList<T> as the datasource at runtime.  I am unable to find a way to assign the class as a datasource at design time so I can set the report layout.  Has anyone done this?

I am using VS2005, Framework 2.0 with ReportViewer