日期:2014-05-20  浏览次数:20831 次

reportviewer报表高手请进,一天未work out来的问题
  
忙了一天的报表控件reportviewer,看了很多网上的方法,挨个测试了一遍,测试时网页均不显示数据。
下面是我最终的代码County_union_SectorTownTableAdapter是添加的数据集文件(.xsd)文件成的类,cus的GetData()得到的是表“County_union_SectorTown”的数据(这个做断点测试没有问题,能正常读取到记录)
ReportViewer1.LocalReport.ReportPath = Server.MapPath("Manage_city.aspx_report.rdlc");
             County_union_SectorTownTableAdapter cus = new County_union_SectorTownTableAdapter();

             Manage_city_report.County_union_SectorTownDataTable gvcr = cus.GetData(); ;
           
            ReportDataSource rds = new ReportDataSource("County_union_SectionTown", gvcr);//这个引号的County_union_SectionTown是我随便起的名字,不知道跟这个又没有关系
            this.ReportViewer1.LocalReport.DataSources.Add(rds);

            ReportViewer1.DataBind();
            
            ReportViewer1.LocalReport.Refresh();
------最佳解决方案--------------------
设置一下reportviewer的报表源为空
------其他解决方案--------------------
建議你用ODBC連接,用存儲過程形式做報表,就不存在此問題。
------其他解决方案--------------------
不能随便起名称,要数据集名_表名