【问题标题】:Using datatable as datasource in micrsosoft report viewer在 Microsoft 报表查看器中使用数据表作为数据源
【发布时间】:2012-07-26 15:01:31
【问题描述】:

是否可以将数据表用作reportviewer 组件的数据源?你能提供参考或简单的步骤吗?

还有一件重要的事情:我正在使用 reportviewer for webforms (ASP.net)

【问题讨论】:

    标签: c# asp.net datatable reportviewer


    【解决方案1】:

    试试这样的。

    this.reportViewer.LocalReport.DataSources.Clear(); 
    DataTable dt = new DataTable(); 
    dt = this.inputValuesTableAdapter.GetData();     
    
    Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt); 
    
    this.reportViewer.LocalReport.DataSources.Add(rprtDTSource); 
    this.reportViewer.RefreshReport(); 
    

    希望对你有帮助

    【讨论】:

    • 是否可以在设计时指定该数据源?
    • @seeker 你是什么意思?举个例子
    • 报告有设计大师。我在那里放置了一些文本和表格(reportviewer 控件)来表示我的数据表。如何将报告文件(.rdlc)中的特定表设置为绑定到数据表?
    • 谢谢,这是正确的方向,但我仍然无法弄清楚如何在设计大师中添加数据源。我只能在运行时执行此操作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 2016-07-17
    • 1970-01-01
    • 2023-03-15
    相关资源
    最近更新 更多