c# - 设置日期时间参数

标签 c# visual-studio-2012 reportviewer

正如您在下图中看到的,RDLC 支持 DateTime 参数类型。 enter image description here

我正在尝试像这样设置参数,但是这段代码没有编译错误,因为没有构造函数接受这种类型的参数:

var p = new Microsoft.Reporting.WinForms.ReportParameter("ReportParameter1", DateTime.Now);
LocalReport.SetParameters(p);

有没有办法设置日期时间甚至日期时间? (可为空)作为参数,以便它可以用于进一步的报告计算而无需将其转换为字符串?

最佳答案

ReportParameter 的所有构造函数都不采用 DateTime。 See here.

你或许可以让它工作:

var p = new Microsoft.Reporting.WinForms.ReportParameter("ReportParameter1", DateTime.Now.ToString("MM/dd/yyyy"));

关于c# - 设置日期时间参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16523637/

相关文章:

c# - SignalR 在子域上协商 404

c# - 为什么我的 Grid Tapped 事件没有被调用?

c# - 在 Visual Studio 中设置 Farseer 以使用 C# 和 XNA

asp.net - 如何在不预编译的情况下使用命令行msbuild部署VS2012网站项目?

asp.net - 带有 col、colgroup、tbody 和 thead 的 HTML 表标记在 Visual Studio 2010 和 Visual Studio 2012 中引发编译错误

c# - 由于在另一个线程中创建 ReportViewr 而导致窗口布局更改时,在非常复杂的 WPF 应用程序中卡在未知位置

c# - 不显示reportviewer直接打印RDLC Report

c# - Storyboard /动画的 "handful"影响性能?

windows-8 - 关于设置 Windows 8 Monogame 项目的最新说明是什么?

c# - 未知服务器标记 'rsweb:ReportViewer'