【问题标题】:Some dataset fields don't appear on RDLC report某些数据集字段未出现在 RDLC 报告中
【发布时间】:2012-01-29 14:28:45
【问题描述】:

我创建了包含来自 SqlServer 2008 数据库的表视图的数据集。 然后我创建了一个报告 (rdlc) 并将之前的数据集添加为该报告的来源。 在代码中,我调用了一个函数,该函数从 My Table View 类型返回一个列表,并将该列表分配给创建的报表,如下所示:

ReportDataSource reportSource = new ReportDataSource();
reportSource.Name = "DataSet1";
reportSource.Value = GetData(); // returns List<MyTableViewType>
localReport.DataSources.Clear();
localReport.DataSources.Add(reportSource);
localReport.Refresh();

问题是数据集中的三个字段没有出现在报告中,尽管我确信(通过调试)它们在呈现报告之前已被填充。

任何帮助将不胜感激... 谢谢

【问题讨论】:

  • 你能发布你的MyTableViewType课程吗?类是否设置了Serializable 属性?

标签: rdlc localreport


【解决方案1】:

您必须确保数据库中的 dataFields 名称与报表数据源中声明的名称相同。可能在返回的列表中,字段名称不同。

【讨论】:

  • 没有意义,因为他使用的是强类型类并且没有将ReportDataSource 绑定到数据库。 blogs.msdn.com/b/sqlforum/archive/2011/01/03/…
  • 其实我按照me5说的解决了,DataSet中这三个字段名都是以大写字母开头的,而在类里都是小字母开头的。
【解决方案2】:

如果使用承包商

public xx(Model dbContext)
    {
        this.dbContext = dbContext;
    }

用这个替换

     public xx()
    {
        this.dbContext = new Model();
    }

【讨论】:

    猜你喜欢
    • 2011-07-14
    • 1970-01-01
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    相关资源
    最近更新 更多