本文介绍了ASP.net ReportViewer开发人员问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用Visual Studio 2010中的ASP.net创建一个站点,并且我遇到了Report Viewer控件的问题。我正在尝试使用一个报表查看器控件并动态设置报表名称和数据集。我没有可用的SSRS服务器,因此所有这些都是应用程序的内部服务器。我尝试了两种方法,首先在ASP方面:I am creating a site using ASP.net in Visual Studio 2010 and am having trouble with the Report Viewer control. I am trying to use one report viewer control and set the report name and data sets dynamically. I do not have an SSRS server available so all of this is internal to the application. I've tried two approaches, first on the ASP side:<% if (true) // very simple test { %> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="538px"> <LocalReport ReportPath="AFR\SimpleTest.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="dsTestInReport" Name="dsTest" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:SqlDataSource ID="dsTestInReport" runat="server" ConnectionString="<%$ ConnectionStrings:Survey %>" SelectCommand="SELECT * FROM [trefQuestionType]"> </asp:SqlDataSource> <% } else { %> <rsweb:ReportViewer ID="ReportViewer2" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="538px"> <LocalReport ReportPath="AFR\SimpleTest.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="dsTest" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Survey %>" SelectCommand="SELECT * FROM [trefMinistry]"></asp:SqlDataSource> <%} %> 但我得到的只是一个报告标题没有数据。如果我注释掉If / else,我会得到两个包含数据的完整报告,但如果包含If / else,我什么也得不到。哎呀!所以我决定尝试Code Behind ...But all I got was a single report header with no data. If I comment out the If / else, I get two complete reports with data, but with the If / else included, I get nothing. Argh! So I decided to try Code Behind ...// open a connection, etc// get the data into a tableSqlCommand _cmd = new SqlCommand("SELECT * FROM [trefMinistry]", _cn);SqlDataAdapter _da = new SqlDataAdapter(_cmd);System.Data.DataTable _tbl = new System.Data.DataTable();_da.Fill(_tbl);// attach the report and data to the Report Viewer controlReportViewer1.LocalReport.Dispose();ReportViewer1.LocalReport.ReportPath = @"AFR\SimpleTest.rdlc";ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("dsTest", _tbl)); 当我运行它时,我收到错误: 报告处理中出现意外错误。 值不能为空。参数名称:输入 任何指针,提示,帮助或现金将真诚地感谢。 (抱歉这个长度,只是想完成。)When I ran this, I got the error:"An unexpected error occurred in Report Processing.Value cannot be null. Parameter name: input"Any pointers, tips, help or cash would be sincerely appreciated. (Sorry for the length, just trying to be complete.)推荐答案 But all I got was a single report header with no data. If I comment out the If / else, I get two complete reports with data, but with the If / else included, I get nothing.哎呀! So I decided to try Code Behind ...But all I got was a single report header with no data. If I comment out the If / else, I get two complete reports with data, but with the If / else included, I get nothing. Argh! So I decided to try Code Behind ...// open a connection, etc// get the data into a tableSqlCommand _cmd = new SqlCommand("SELECT * FROM [trefMinistry]", _cn);SqlDataAdapter _da = new SqlDataAdapter(_cmd);System.Data.DataTable _tbl = new System.Data.DataTable();_da.Fill(_tbl);// attach the report and data to the Report Viewer controlReportViewer1.LocalReport.Dispose();ReportViewer1.LocalReport.ReportPath = @"AFR\SimpleTest.rdlc";ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("dsTest", _tbl)); When I ran this, I got the error: \"An unexpected error occurred in Report Processing. Value cannot be null. Parameter name: input\" Any pointers, tips, help or cash would be sincerely appreciated. (Sorry for the length, just trying to be complete.)When I ran this, I got the error:"An unexpected error occurred in Report Processing.Value cannot be null. Parameter name: input"Any pointers, tips, help or cash would be sincerely appreciated. (Sorry for the length, just trying to be complete.) 这篇关于ASP.net ReportViewer开发人员问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!