c# - 使用 asp.net c# 在 Reportviewer 中设置文本框值

标签 c# asp.net reportviewer

我有一个包含文本框和 tablix 的报表查看器。 Tablix 是使用数据源填充的(它使用带有查询字符串中的 2 个参数的存储过程获取数据)。 我如何将查询字符串的值指定为我的 reportviewer 文本框的值。 就像是: 此 ReportfFrom 查询字符串 val1 以查询字符串 val 2。

标记:

<rsweb:ReportViewer ID="ReportViewer1" runat="server" 
    CssClass="ReportAlignment" Font-Names="Verdana" Font-Size="8pt" 
    InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" 
    WaitMessageFont-Size="14pt" Width="550px">
    <LocalReport ReportPath="TempEmpWageSummaryReport.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="LoadWageSummary" Name="DataSet1" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer>
<asp:SqlDataSource ID="LoadWageSummary" runat="server" 
    ConnectionString="<%$ ConnectionStrings:stockerConnectionString %>" 
    SelectCommand="procTempEmployeeWageSummaryReport" 
    SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:QueryStringParameter Name="startDate" QueryStringField="start" 
            Type="String" />
        <asp:QueryStringParameter Name="endDate" QueryStringField="end" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

背后的代码

protected void Page_Load(object sender, EventArgs e)
    {
        string start = Server.UrlDecode(Request.QueryString["start"]);
        string end = Server.UrlDecode(Request.QueryString["end"]);
        //this.ReportViewer1.LocalReport.ReportEmbeddedResource = "TempEmpWageSummaryReport.rdlc";
        string param0 = "GROUPED TEMPORARY EMPLOYEE WAGE SUMMARY REPORT FROM " + start + "to " + end;
        ReportParameter rp = new ReportParameter("ReportParameter1", param0);
        this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

        this.ReportViewer1.LocalReport.Refresh();

        //BindReport();
    }

谢谢。

最佳答案

如果您在文本框中保存包含期望值的报告,您可以通过报告定义中的 xml 进行处理以获取该值,但我不推荐这样做。 为此,您最好在报告外部设置一个文本框,然后将其提供给查询以获取数据。

除上述情况外,我几乎可以肯定,从用户指定的报告中的文本框中获取值是不可能的,除非保存报告,然后您通过报告的定义进行处理并获取值如果您不知道自己在做什么,那将是一种痛苦。

关于c# - 使用 asp.net c# 在 Reportviewer 中设置文本框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13169719/

相关文章:

c# - 创建报表查看器报表时在另一个数据表中查找值

asp.net - ssrs reportviewer加载到无穷大而没有错误消息

c# - IdentityServer4 升级到 .NET Core 2.0 的问题(AddConfigurationStore、AddOperationalStore)

c# - WebBrowser 保持 url/uri 编码不解码

c# - 用压降控制遥控车

c# - 如何将从 MySQL 数据库获取的单行存储在变量中?

c# - 创建新模型时上传图像

asp.net - Telerik 控制 radscheduler 在 IE 11 上无法正常工作

javascript - 使用 VB 在 ASP.NET 中打开一个新窗口

c# - 如何删除下一页页眉中的一些数据(RDLC 报告)