【问题标题】:How to Bind a ReportViewer to an IEnumerable<T>如何将 ReportViewer 绑定到 IEnumerable<T>
【发布时间】:2011-06-20 16:12:44
【问题描述】:

我开始使用 MS-Report,我想知道是否可以将 ReportViewer 组件直接绑定到 IEnumerable 集合,而不是创建 DataSourceControl(ObjectDataSource、EntityDataSource、SqlDataSource 等...) ,与我们处理数据绑定组件的方式类似(使用 Datasource 属性而不是 DataSourceID)。我知道 ReportViewer 没有“DataSource”属性,但我想知道是否有类似的方法。

在我的情况下,我正在使用具有存储库模式和实体框架 (POCO EF 4.1) 的 nTier 应用程序。

谢谢!

【问题讨论】:

  • 您是否检查了在本地处理模式下将业务对象数据源与 ReportViewer Web 服务器控件一起使用?link

标签: c# asp.net reporting-services reporting reportviewer


【解决方案1】:

您需要为您的报告创建一个reportDataSource(使用设计器)。您将要求提供 reportDateSource 的名称和类型(您的 IEnumerable 集合的实体类型)(假设您将 id 命名为“test”并且您的数据类型是 Client)

ReportDataSource reportDataSource = New ReportDataSource("test", listofclients);
localreport.DataSources.Add(reportDataSource);

就是这样。

【讨论】:

  • 谢谢@Jonathan。它有很大帮助,让事情变得更容易!
猜你喜欢
  • 2011-06-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-04
  • 1970-01-01
相关资源
最近更新 更多