更新时间:2022-03-12 07:54:38
您的 button1_Click 应如下所示:
Your button1_Click should look like this:
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = GetSPResult();
reportViewer1.Visible = true;
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(new
Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));
}
请注意,从 GetSPResult 返回的 DataTable 应添加到报告中,而不是像您的代码中那样新创建的空白表.
Note that the DataTable returned from GetSPResult should be added to the report not a newly created blank table as in yourt code.