开发者

passing a null datetime to reportparameter class?

开发者 https://www.devze.com 2023-01-30 05:40 出处:网络
How can I put a null value on datetime variable type? I tried to make it nullable value, but I need to use it in ReportParameter() method to send it to my report b开发者_如何学编程ut ReportParameter(

How can I put a null value on datetime variable type?

I tried to make it nullable value, but I need to use it in ReportParameter() method to send it to my report b开发者_如何学编程ut ReportParameter() constructor cannot take a nullable value and the ReportParameter() take just a string values!


The various constructor overloads for ReportParameter only take in a string or string array as acceptable input.

passing a null datetime to reportparameter class?

And the ReportParameter.Values property itself is actually a StringCollection in order to force the serialization to happen at compile time.

passing a null datetime to reportparameter class?

But you can pass a null value with string typing per this thread on Passing NULL parameter from aspx page to Report Server like this:

var rp = new ReportParameter("ServiceType_cd", new string[] { null });

Or per this question Report Viewer: Set null value to Report Parameters having allow null true, you can pass in a value like this:

string str = null;
var rp = new ReportParameter("ServiceType_cd", str));


you can create FailIfNull() extension method for this purpose. Please look here for more information about extension methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消