Binding object with Listlt;gt; to Crystal Report(用 Listlt;gt; 绑定对象到水晶报表)
问题描述
我有一个包含一些属性的类,其中一个是子对象的 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() { ... }
}
我正在尝试将此对象(示例中的发票)绑定到 Crystal Report(使用 VS2008 水晶报表设计器),当我在字段资源管理器中显示简单属性(名称、CreatedDate)时,子集合没有.我尝试使用 ArrayList (如建议( 如何使用强类型列表作为 Crystal Reports 的数据源 ) 但这不起作用.
I am trying to bind this object (Invoice in the example) to a Crystal Report (using VS2008 crystal report designer) and while I get the simple properties (Name, CreatedDate) to show up in Field Explorer the child collection does not. I have tried using an ArrayList (as suggested ( How can I use strongly typed lists as the datasoruce for a Crystal Reports ) but that did not work.
推荐答案
经过一番搜索和试验,我未能成功尝试将报表绑定到包含子集合的自定义对象.我没有使用 .Net 对象,而是使用 XSD shema 设计了报告,并在运行时生成了一个 xml 文件,并将成本报告的数据源设置为我使用 .ReadXML 方法构建的 DataSet.
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);
这篇关于用 List<> 绑定对象到水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用 List<> 绑定对象到水晶报表
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何激活MC67中的红灯 2022-01-01