C# RDLC文件中的自定义数据源

C# RDLC文件中的自定义数据源,c#,wpf,winforms,reporting-services,rdlc,C#,Wpf,Winforms,Reporting Services,Rdlc,我创建了一个RDLC文件,其中我使用datatable作为ReportDataSource,但现在我想使用自定义classinsted of data table,请为此提供建议 ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc repor

我创建了一个RDLC文件,其中我使用datatable作为ReportDataSource,但现在我想使用自定义classinsted of data table,请为此提供建议

 ReportDataSource reportDataSource = new ReportDataSource();



   reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc

            reportDataSource.Value = dt;// Datatable 

            reportViewer.LocalReport.ReportPath = // Path of the rdlc file

您可以向project中添加新的报告/报告向导,在数据源配置向导中添加数据集时,选择对象,然后按照向导选择数据模型并创建报告

然后在表单上放置一个报表查看器,并从智能标记窗口(单击报表查看器右上角的小箭头)选择您的报表,您将看到一个
BindingSource
将添加到表单中,该绑定源将用作报表的数据源

要将数据传递到报表,在表单加载事件中,您可以将
列表
传递到绑定源,然后
调用此.reportViewer1.RefreshReport()

有关更多信息,您可以查看:

您可以将新的报告/报告向导添加到project中,并在数据源配置向导中添加数据集时选择对象,然后按照向导选择数据模型并创建报告

然后在表单上放置一个报表查看器,并从智能标记窗口(单击报表查看器右上角的小箭头)选择您的报表,您将看到一个
BindingSource
将添加到表单中,该绑定源将用作报表的数据源

要将数据传递到报表,在表单加载事件中,您可以将
列表
传递到绑定源,然后
调用此.reportViewer1.RefreshReport()

有关更多信息,您可以查看:
首先,必须从自定义类创建数据

ReportDataSource reportDataSource = new ReportDataSource
{
    Name = "DataSet1",
    Value = data
};
rpvAllReportViewer.LocalReport.DataSources.Add(reportDataSource );
rpvAllReportViewer.LocalReport.ReportEmbeddedResource = //your report Path
然后添加参数(如果有)

ReportParameter parameter1 = new ReportParameter("ParameterName1", parameter1Value);
rpvAllReportViewer.LocalReport.SetParameters(new[] { parameter1 });
rpvAllReportViewer.RefreshReport();

首先,必须从自定义类创建数据

ReportDataSource reportDataSource = new ReportDataSource
{
    Name = "DataSet1",
    Value = data
};
rpvAllReportViewer.LocalReport.DataSources.Add(reportDataSource );
rpvAllReportViewer.LocalReport.ReportEmbeddedResource = //your report Path
然后添加参数(如果有)

ReportParameter parameter1 = new ReportParameter("ParameterName1", parameter1Value);
rpvAllReportViewer.LocalReport.SetParameters(new[] { parameter1 });
rpvAllReportViewer.RefreshReport();