我在我的 aspx 项目中使用了 Telerik 报告,在这个项目中我希望用户可以设置报告的某些项目。为了实现这个目标,我使用参数并创建参数,如图 1 所示,图 2 中是该参数的属性,我在报告中使用它,如图 3 所示,但至少当我运行我的项目时,我看到图 4 我的问题是: 这是我的代码错误吗?当我使用它们加载并在参数区域中显示的参数时,如何在报告空间中由用户设置报告项目,如何在报告的详细空间中显示它们?我的代码有什么问题吗? 这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using schduleing_report;//its my dll report
namespace telerikreporttest
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Report2 report = new Report2();
var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = new schduleing_report.Report2();
instanceReportSource.Parameters.Add("param", "hi it work");
this.ReportViewer1.ReportSource = instanceReportSource;
instanceReportSource.Parameters.Add("testparam", "textbox2 is work too");
ReportViewer1.RefreshReport();
}
}
}
最佳答案
当您定义了第一个参数“param”时,您就选择了 MultiValue=True。因此,当您将参数的值直接读取到文本框中时 - 它会显示对象数组的类型。多值将使文本框接受多个值。
相反,如果您设置 MultiValue=false,则该参数将始终仅保留 1 个值,然后它将在报告上显示正确的值。
如果您需要在 param 参数上设置 MultiValue=true - 则执行以下操作将文本放入报告的文本框中:
- 在设计器中 - 右键单击文本框。选择表达式
- 在编辑表达式窗口中 - 添加以下表达式 - = Join(", ",Parameters.param.Value)
运行报告,现在您将正确的文本设置为文本框的值。
Join() 函数有 2 个参数。第一个是分隔符字符串,第二个是包含需要连接的值的对象数组。所以当MultiValue设置为true时,参数值为object[]。因此,您需要使用 join() 函数将其转换为文本格式。
希望这有帮助。
关于asp.net - 如何在详细空间的 Telerik 报告的文本框中传递参数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17122431/