用绑定列表与LT对象;>水晶报表
我有一个包含一些特性,包括一个是一个List<类;>儿童的对象
I have a class that contains a few properties including one that is a List<> of children objects.
简单的例子:
public class LineItem
{
public string Name { get; set; }
public decimal Amount { get; set; }
}
public class Invoice
{
public string Name { get; set; }
public DateTime CreatedDate { get; set; }
public List<LineItem> LineItems { get; set; }
public Invoice() { ... }
}
我尝试这个对象(发票中的例子),以水晶报表(使用VS2008水晶报表设计器)绑定,虽然我得到了简单的属性(名称,CreatedDate),以显示在字段资源管理器子集合没有。我一直在使用一个ArrayList(的建议(的 http://stackoverflow.com/questions/1362829/how-can-i-use-strongly-typed-lists-as-the-datasoruce-for-a-crystal-reports )但没有奏效。
在一个位的寻找和实验我是在尝试将报告绑定到一个自定义的不成功对象包含一个子集,而是使用.NET对象的,我设计采用XSD玛的报告,并在运行时生成一个XML文件,并设置成本报表的数据源,我用.ReadXML方法建立了一个数据集。
After a bit of searching and experimenting I was unsuccessful in attempting to bind the report to a custom object that contained a child collection. Instead of using a .Net object I designed the report using a XSD shema and at runtime generated an xml file and set the cost report's datasource to a DataSet that I built using the .ReadXML method.
var exportData = new XDocument(....);
var dataSet = new System.Data.DataSet();
dataSet.ReadXml(exportData.CreateReader());
var report = new ReportDocument();
report.Load("...");
report.SetDataSource(data);