我有一个100%工作的ReportViewer,但我需要它以PDF直接打开
并且我的代码示例中我将报表查看器与数据绑定在一起。
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportDataSource source = new ReportDataSource("dsGetTrnsactions", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(source);
ReportViewer1.DataBind();
ReportViewer1.LocalReport.Refresh();
答案 0 :(得分:2)
您需要获取显示PDF文件的字节数组,然后您需要打开一个包含PDF文件的新窗口。试试这个:
byte[] file = ReportViewer1.LocalReport.Render(some parameters);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline;filename=Test.pdf");
Response.Buffer = true;
Response.Clear();
Response.BinaryWrite(file);
Response.End();