c# - 如何在reportviewer控件中传递报表参数

标签 c# asp.net

我想显示带有参数“文本框和按钮”的“ReportView”,例如。就像一个搜索按钮。你能给我一些代码示例吗?

提前致谢。

最佳答案

希望您使用的是 asp.net WebForms,

  1. 打开您想要添加参数的报告。
  2. 在“报告数据” Pane (CTRL+ALT+D) 中,有一个参数文件夹。正确的 单击它以添加新参数,来自报告参数 属性对话框指定参数名称,即 ReportParam1 和 单击“确定”进行添加。
  3. 将新参数拖到报告上
  4. 下面的代码(C#)从文本框中获取一个值并将其显示在 报告。

    reportViewer1.LocalReport.ReportEmbeddedResource = "path_to_the_embedded_report";
        ReportParameter[] parameters = new ReportParameter[1];
        parameters[0] = new ReportParameter("ReportParam1", textbox1.Text, true);
        reportViewer1.LocalReport.SetParameters(parameters);
        reportViewer1.RefreshReport();

    您可能需要解析一些引用并通过 NuGet 将报表查看器添加到您的项目。

希望有帮助。

关于c# - 如何在reportviewer控件中传递报表参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48161943/

相关文章:

c# - 如何在Push Sharp库的APNS有效负载中添加类别以进行交互式通知iOS

c# - 更快地实现总和(用于 Codility 测试)

.net - 防止浏览器在刷新时显示查询重新提交对话框

c# - 解析 dd/MM/yyyy 格式时出现日期时间解析错误。字符串未被识别为有效的日期时间

c# - 在 C# 中将字符串列表添加到 OracleCommand.Parameters

c# - Azure 资源管理器

c# - 无法将当前 JSON 对象(例如 {"name":"value"})反序列化为类型 'System.Collections.Generic.List` 1

c# - 即时格式化 html 日期和数字

c# - 以编程方式控制 SQL Server Reporting Services 报表查看器

c# - LINQ to SQL 从字符串创建查询