【问题标题】:Report using RDLC can't load dataset使用 RDLC 的报告无法加载数据集
【发布时间】:2014-08-20 02:51:25
【问题描述】:

我正在尝试使用RDLC 文件进行报告。我正在关注此链接:

http://www.mindstick.com/Articles/13169999-ef3b-496c-b502-caef973c3bb2/?Using%20ReportViewer%20in%20WinForms%20C

所以我创建了一个 RDLC 文件,并将我的 tax 对象导入到此报告中,我的税务对象的结构如下:

public partial class Tax
    {
        public Tax()
        {
            this.Innovices = new HashSet<Inovice>();
        }
        [DisplayName("شناسه")]
        public int Id { get; set; }
        [DisplayName("عوارض شهرداری")]
        public Nullable<double> MunicipalTax { get; set; }
        [DisplayName("مالیات بر ارزش افزوده")]
        public Nullable<double> AdditionalTax { get; set; }
        [DisplayName("سال مالی")]
        public string Year { get; set; }

        public virtual ICollection<Inovice> Innovices { get; set; }
    }

在这里您可以看到绑定对象到我的报告:

我在 y 表单中放置了一个报告查看器,我在 `formload 中编写了这段代码

 private void Form1_Load(object sender, EventArgs e)
        {
            InvoiceRepository.TaxRepository obj = new TaxRepository();
            List<InnoviceDomainClass.Tax> list = obj.GetAll().ToList();

            reportViewer1.LocalReport.DataSources.Clear(); //clear report
            reportViewer1.LocalReport.ReportEmbeddedResource = "Factor169.Report.Report1.rdlc";
                // bind reportviewer with .rdlc

            Microsoft.Reporting.WinForms.ReportDataSource dataset =
                new Microsoft.Reporting.WinForms.ReportDataSource("Dataset1", list); // set the datasource
            reportViewer1.LocalReport.DataSources.Add(dataset);
            dataset.Value = list;

            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport(); // refresh report
        }`

但是执行后的结果是这样的:why ?

【问题讨论】:

    标签: c# winforms reporting-services report error-reporting


    【解决方案1】:
    Microsoft.Reporting.WinForms.ReportDataSource dataset =
                new Microsoft.Reporting.WinForms.ReportDataSource("Dataset1", list); 
    

    应该是DataSet1

    ReportDataSource("DataSet1", list); //The "s"
    

    报表数据源的名称必须与报表中的数据集相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-02
      • 2011-07-14
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多