如何在asp.net的reportviewer中显示动态生成的数据表

How to show dynamically generated datatable in reportviewer in asp.net?(如何在asp.net的reportviewer中显示动态生成的数据表?)
本文介绍了如何在asp.net的reportviewer中显示动态生成的数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用中有一个 ReportViewer(.rdlc).我想在表对象的 Reportviewer 中显示一个 datatable,它是从代码隐藏动态生成的.

I've a ReportViewer(.rdlc) in my app. I want to show a datatable, which is generated dynamically from codebehind, in Reportviewer in Table object.

如何做到这一点?数据集必须通过代码隐藏发送到报告.

How to do this? dataset has to be sent to report through codebehind.

我有我的代码隐藏文件

  DataTable dt = Session["ReportOnUser"] as DataTable;
  if (dt.Rows.Count > 0)
  {
      ReportDataSource rds = new ReportDataSource("ReportOnUser", dt);
      ReportViewer1.LocalReport.DataSources.Clear();
      ReportViewer1.LocalReport.DataSources.Add(rds);
      ReportViewer1.LocalReport.Refresh();
  }

aspx 文件:

 <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="800px">
    <LocalReport ReportPath="ReportsReport1.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="ReportOnUser" Name="ReportOnUser" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer>

我添加了一个没有设计的 rdlc 文件或 xsd 文件 Report1.rdlc.

I have adde an rdlc file with No design or xsd file Report1.rdlc.

推荐答案

上面的代码运行良好.唯一的问题是添加的Microsoft.ReportViewer.WebForms"dll 版本不同.

The Code above is working perfectly. the only issue was 'Microsoft.ReportViewer.WebForms' dll added was of different version.

这篇关于如何在asp.net的reportviewer中显示动态生成的数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)