首页 > 解决方案 > c# RDLC ASPNET 表单页面中的新列为空

问题描述

我有一个呈现 .rdlc 报告的 ASPNET 表单页面。我的意图是在报表中使用的 SQL 过程中添加 2 个新列以显示在页面中。

因此,我更新了成功添加新列的过程。

SQL server 中的查询结果

我可能会在现有的 .xsd 中添加与过程 SQL 结果同名的 2 个新列。

在此处输入图像描述

所以,我去了我的 .rdlc 并重新创建了我DataSet的报告数据

报告数据中的我的数据集

在我的 .rdlc[Design] 中,我毫无问题地添加了 2 个新列。 我的 .rdlc 设计

当我运行我的网站并呈现 .rdlc 页面时,除了新的 2 列之外,所有列都显示有值。 我的网站并呈现 .rdlc

我的 aspx 和我的 aspx.cs 没有受到修改,因为我没有更改 ReportPath、rsweb:ReportViewer、DataSourceId="ObjectDataSource1" 之类的所有内容。

我不明白为什么新列是空的,而其他列正在返回数据。

更多信息:

aspx 报表绑定数据与上面的代码不同:

    <asp:Panel...>
                    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" HyperlinkTarget="_blank"
                        Width="816px" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowParameterPrompts="False" InteractiveDeviceInfos="(Collection)">
                        <LocalReport ReportPath="The path of my .rdlc file" EnableExternalImages="True" EnableHyperlinks="True">
                            <DataSources>
                                <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="My DataSet name in Report Data" />
                            </DataSources>
                        </LocalReport>
                    </rsweb:ReportViewer>
                </asp:Panel>

 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="[My DAO Method]" TypeName="[My DAO Class]">
                    <SelectParameters>

[我的 DAO 方法]”和“[我的 DAO 类] 正在页面上工作并返回我的目标对象的列表

IList<TheObjectTarget>

我在Sql Profiler中获取了在 [My DAO Method] 中执行的过程,并成功获取了新列。

当我设置参数时,在点击事件中执行报告,使其可见,创建 LocalReport.Refresh 并启用面板:

 ReportViewer1.LocalReport.SetParameters(param);
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();
                MyPanel.Visible = true;

有人知道吗?

标签: c#rdlcreportviewerlocalreport

解决方案


我遇到了同样的问题,但我使用的是LINQtoSQL类 ( dbml),我必须刷新对我的存储过程的引用(删除它并从 dbml 类中再次添加它)。也许你必须对你的DataSource.


推荐阅读