1

请帮助我,我需要你的时间。这是我的代码下面,它只显示标题而不是行数据。但是数据来自这个数据库,请看一下。谢谢

 FineDataSet.CountryDataTable fc = new FineDataSet.CountryDataTable();
 FineDataSetTableAdapters.CountryTableAdapter fsad = new FineDataSetTableAdapters.CountryTableAdapter();

 fsad.Fill(fc);
 //ReportDataSource rds = new ReportDataSource("DataSet12_SubCityGrandTotal", fsw.TableName);
 //rds.DataSourceId = fs;
 ReportViewer1.LocalReport.EnableExternalImages = true;
 ReportViewer1.ProcessingMode = ProcessingMode.Local;
 ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/Myreport2.rdlc");
 ReportViewer1.Visible = true;
 Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
 rds.Name = "DataSet1";

 rds.Value =  fc.TableName;
 ReportViewer1.LocalReport.DataSources.Clear();
 ReportViewer1.LocalReport.DataSources.Add(rds);
 //ReportViewer1.ServerReport.Refresh();
 ReportViewer1.LocalReport.Refresh();
 ReportViewer1.DataBind();

 GridView1.DataSource = fc;
 GridView1.DataBind();
4

1 回答 1

0

如果有人来这里-这就是您必须将数据从数据库设置为报告的方式-

   viewer.LocalReport.DataSources.Add(new ReportDataSource("dataset_name_as_in_rdlc_file", dataset.Tables[0]));

这里的名称“dataset_name_as_in_rdlc_file”应该与您使用的 rdlc 文件中的名称相同。dataset.Tables[0] 是您从查询中获得的数据集。

于 2013-12-10T07:18:27.230 回答