1

我创建了包含来自 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();

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

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

4

2 回答 2

2

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

于 2012-02-16T10:33:10.710 回答
0

如果使用承包商

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

用这个代替

     public xx()
    {
        this.dbContext = new Model();
    }
于 2020-04-02T08:38:24.853 回答