使用报表查看器在Asp.Net中显示RDLC报表

使用报表查看器在Asp.Net中显示RDLC报表,asp.net,visual-studio-2010,c#-4.0,rdlc,Asp.net,Visual Studio 2010,C# 4.0,Rdlc,我使用VS2010创建了一个示例web应用程序。添加了数据集和报表,并创建了只返回一行的SP。目前没有包含任何变量。只需简单的SP,不需要任何参数。在web应用程序中,添加了一个aspx页面,并在该页面中添加了一个报表查看器控件。 我的Aspx页面如下所示: <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDe

我使用VS2010创建了一个示例web应用程序。添加了数据集和报表,并创建了只返回一行的SP。目前没有包含任何变量。只需简单的SP,不需要任何参数。在web应用程序中,添加了一个aspx页面,并在该页面中添加了一个报表查看器控件。 我的Aspx页面如下所示:

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
    </rsweb:ReportViewer>
protected void Page_Load(object sender, EventArgs e)
        {
            ReportViewer1.Visible = true;
            ReportDataSource dataSource = new ReportDataSource("DataSet1", LoadData().Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(dataSource);
            ReportViewer1.LocalReport.Refresh();
        }

        private DataSet LoadData()
        {
            var dataset = new DataSet();
            using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["CString"].ConnectionString))
            {
                var command = new SqlCommand("[spSampleReport]")
                                  {
                                      Connection = con,
                                      CommandType = CommandType.StoredProcedure
                                  };

                var adap = new SqlDataAdapter(command);
                con.Open();
                adap.Fill(dataset, "DataSet1");
            }

            return dataset;
        }
在我的web配置中,在httphandlers部分添加了以下内容:


运行时,页面上没有显示任何内容。甚至报表查看器工具栏也不会显示

我不是ReportViewer专家,但我认为您需要一个.rdlc来告诉报表查看器要呈现什么

ReportViewer.LocalReport.ReportPath = Server.MapPath(string.Format(@"~\Reports\Definitions\{0}.rdlc", reportName));

确保.rdlc中的数据集名称与创建报表数据源时指定的数据源相同。我发现了一个在asp.net中生成rdlc报表的好示例,其中包含代码示例


调试时引发的错误?