【问题标题】:Sorting Report data in a ReportViewer using a BindingSource使用 BindingSource 对 ReportViewer 中的报表数据进行排序
【发布时间】:2009-01-08 15:51:53
【问题描述】:

我正在尝试让 ReportViewer 显示来自 BindingSource (VB.Net Winforms) 的数据。

我在基础数据集上构建了报告。然后我将数据源实例配置为 BindingSource。我认为这将应用排序、过滤等。但看起来数据来自数据集而不是 BindingSource。

我怀疑我遗漏了一些简单的东西。

更新:或者它不是那么简单 - 我几天前发布了这个,但仍然没有人知道答案!也许我正在尝试做一些无法做到的事情?

【问题讨论】:

    标签: vb.net ado.net reportviewer bindingsource


    【解决方案1】:

    您需要在报告中指定排序(在 RDL 中),因为它应用了自己的排序逻辑。

    【讨论】:

      【解决方案2】:

      这是我使用的解决方案。您将 Bi​​ndingSource 中的数据放入 DataTable 中,然后让 Report 使用 DataTable。

          ReportViewer1.Reset()
          Dim dt As DataTable
          dt = DirectCast(Form1.ProgActnBindingSource.Current, DataRowView).DataView.ToTable
      
          Dim rs = New ReportDataSource
          rs.Name = "name"
          rs.Value = dt
      
          ReportViewer1.ProcessingMode = ProcessingMode.Local
          ReportViewer1.LocalReport.DataSources.Clear()
          ReportViewer1.LocalReport.DataSources.Add(rs)
          ReportViewer1.LocalReport.ReportEmbeddedResource = "projectname.Report1.rdlc"
      
          Me.ReportViewer1.RefreshReport()
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-05-18
        • 2016-10-29
        • 1970-01-01
        • 2011-01-25
        • 2012-02-24
        • 1970-01-01
        • 2018-04-01
        相关资源
        最近更新 更多