【问题标题】:Showing RDLC report in Asp.Net with report viewer使用报表查看器在 Asp.Net 中显示 RDLC 报表
【发布时间】:2013-09-17 23:04:31
【问题描述】:

我正在使用 VS 2010 并创建了一个示例 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;
        }

在我的网络配置中,在 httphandlers 部分添加了以下内容:

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

【问题讨论】:

  • 调试时抛出错误?

标签: asp.net visual-studio-2010 c#-4.0 rdlc


【解决方案1】:

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

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

确保 .rdlc 中的 DataSet 名称与创建时指定的 DataSource 相同ReportDataSource

【讨论】:

    【解决方案2】:

    我找到了一个很好的例子,用代码示例在 asp.net 中生成 rdlc 报告

    http://www.dotnetsharepoint.com/2013/09/how-to-create-rdlc-reports-in-aspnet.html#.UjhvAsafh88

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      相关资源
      最近更新 更多