gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 13:53:05 25 4
gpt4 key购买 nike

我有一个包含文本框和 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com