gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:43:18 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com