用绑定列表与LT对象;>水晶报表 [英] Binding object with List<> to Crystal Report

查看:100
本文介绍了用绑定列表与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);

这篇关于用绑定列表与LT对象;&GT;水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆