如何以编程方式加载reportviewer [英] how to load reportviewer programaticaly
本文介绍了如何以编程方式加载reportviewer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个reportviewer,当我在pageload上运行它时,出现此错误未为数据源提供数据源实例EmployeeDataSet
我该怎么办?
选中代码onpageload
I have a reportviewer and when i run it on pageload I get this error "A data source instance has not been supplied for the data source EmployeeDataSet
What should i do?
Checkt the code onpageload
ReportViewer1.ProcessingMode = ProcessingMode.Local;
LocalReport report = ReportViewer1.LocalReport;
report.ReportPath = "Report/Report.rdlc";
DataSet dSet = systemBusinessLayer.PLZgetAllEmployeesInfo();
ReportDataSource dsAllEmployees = new ReportDataSource();
dsAllEmployees.Name = "dSet";
dsAllEmployees.Value = "dSet";
report.DataSources.Add(dsAllEmployees);
以下是我班上的方法
Below is the methos in my class
#region GetALLEmployees()
public DataSet PLZgetAllEmployeesInfo()
{
using (SqlConnection conn = new SqlConnection(ConnString))
{
SqlCommand cmd = new SqlCommand("procGetAllEmployees", conn);
cmd.CommandType = CommandType.StoredProcedure;
DataSet dTable = new DataSet("dSet");
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dTable, "dSet");
return dTable;
}
}
#endregion
推荐答案
选中此
未为数据源提供数据源实例"带有报告的异常查看器控件 [ ^ ]
Check this
"A data source instance has not been supplied for the data source" exception w/ Report Viewer Control[^]
我也遇到了这类问题,但是当我将代码更改为以下方式时,效果很好.
this.report .LocalReport.ReportPath =";
this.report .LocalReport.DataSources.Clear();
this.report .LocalReport.Refresh();
this.report .LocalReport.ReportPath = Server.MapPath(〜/Reports/RecieptVoucherForStudent.rdlc");
ReportDataSource rptUserHeader =新的Microsoft.Reporting.WebForms.ReportDataSource(" DatasetName ",dt);
this.report.LocalReport.DataSources.Add(rptUserHeader);
this.report.LocalReport.Refresh();
DatasetName-数据集是在App_Code数据集中创建的
I am also getting this type of issues but when i change the code to the following way it works fine.
this.report .LocalReport.ReportPath = "";
this.report .LocalReport.DataSources.Clear();
this.report .LocalReport.Refresh();
this.report .LocalReport.ReportPath = Server.MapPath("~/Reports/RecieptVoucherForStudent.rdlc");
ReportDataSource rptUserHeader = new Microsoft.Reporting.WebForms.ReportDataSource("DatasetName", dt);
this.report.LocalReport.DataSources.Add(rptUserHeader);
this.report.LocalReport.Refresh();
DatasetName- The Dataset is created in the App_Code Dataset
这篇关于如何以编程方式加载reportviewer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文