我使用2个数据集数据集生成此代码的pdf文件,但是,pdf中的数据仅来自ds.Tables [0],而不是ds.Tables [1]。请建议解决方案..我的代码如下..
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.Reset();
viewer.LocalReport.ReportEmbeddedResource = @"D:\Projects\NIKHIL\NIKHIL\Report3.rdlc;
viewer.LocalReport.ReportPath = @"D:\Projects\NIKHIL\NIKHIL\Report3.rdlc;
viewer.LocalReport.DataSources.Clear();
viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));
viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", ds.Tables[1]));
viewer.LocalReport.Refresh();
byteViewer = viewer.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out extension, out streamIds, out warnings);
byte[] file = byteViewer;
FileStream stream = new FileStream(FileStorageLocation + "\\" + fileName, FileMode.Create, FileAccess.Write);
stream.Write(file, 0, file.Length);
stream.Close();
答案 0 :(得分:0)
如果您有多个数据源,则必须指定在RDLC文件中引用的数据源。
对于每个表达式,您必须以这种方式编辑公式:
=First(Fields!nameOfYourField.Value, "nameOfYourDataSet")
所以会有两个单元格,一个用于:
=First(Fields!nameOfYourField.Value, "DataSet1")
另一个用:
`=First(Fields!nameOfYourField.Value, "DataSet2")