Reputation: 35
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 but ReportParameter()
constructor cannot take a nullable value and the ReportParameter() take just a string values!
Upvotes: 1
Views: 1270
Reputation: 29957
The various constructor overloads for ReportParameter
only take in a string or string array as acceptable input.
And the ReportParameter.Values
property itself is actually a StringCollection
in order to force the serialization to happen at compile time.
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));
Upvotes: 2
Reputation: 1486
you can create FailIfNull() extension method for this purpose. Please look here for more information about extension methods.
Upvotes: 1