c# - 使用 RDLC 的报告无法加载数据集

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

我正在尝试使用 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; }
    }

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

enter image description here

我在 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
        }`

但是执行后结果是这样的:为什么? enter image description here

最佳答案

Microsoft.Reporting.WinForms.ReportDataSource dataset =
            new Microsoft.Reporting.WinForms.ReportDataSource("Dataset1", list); 

应该是DataSet1

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

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

关于c# - 使用 RDLC 的报告无法加载数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24478172/

相关文章:

c# - Visual Studio 即时窗口 "Internal error in the expression evaluator"

c# - 如何从 Visual Studio C#.net 创建一个文本文件 (.txt) 与自动换行属性禁用?

visual-studio - Visual Studio 2015 中的 SSRS

.net - 您能否为 .NET Winforms 应用程序推荐低成本的自动化测试工具?

C# 定时调用函数

c# - 最大报表处理作业限制 Crystal 报表,这是由于我的代码错误?

reporting-services - 如何让LookupSet显示多行结果

c# Expression Lambda 从字符串到 Func<T>

c# - 如何为 DataGridViewComboBox 列设置值?

c# - DotNetBrowser 的 Browser.GetRemoteDebuggingURL() 返回 string.Empty