【问题标题】:How to set the datasource of RDLC to the return of a specific method如何将RDLC的数据源设置为特定方法的返回
【发布时间】:2017-04-08 01:58:49
【问题描述】:

我想将我的RDLC 报告的datasource 设置为特定方法的返回。但是报告向导无法检测到我的方法。

方法在 DataLayer 命名空间中的 Class Utility 中,而我的报告在另一个类库中 (FinanceReportBundle)。

班级是这样的

namespace DataLayer
{

    public  class Utility
    {

         public static IEnumerable<object> GetAnalysisDataForConsecutiveYears(int year, int periodTypeId, int period)
        {
            ////Business
        } 
    }

 }

【问题讨论】:

    标签: c# visual-studio-2012 rdlc reportviewer class-library


    【解决方案1】:

    您不必在设计器中执行此操作。您可以轻松地在代码中设置数据源,如下所示:

    var dataSource = getmyDataSource();
    var rds = new ReportDataSource("myDataSourceName", dataSource);
    this.reportViewer1.LocalReport.DataSources.Add(rds);
    this.reportViewer1.LocalReport.ReportPath = "path your your rdlc";
    this.reportViewer1.RefreshReport();
    

    【讨论】:

      猜你喜欢
      • 2012-06-17
      • 1970-01-01
      • 2023-03-10
      • 2015-06-06
      • 2011-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-15
      相关资源
      最近更新 更多