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<> 绑定对象到水晶报表


- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 使用 rss + c# 2022-01-01