kevin floyd
Top achievements
Rank 1
kevin floyd
asked on 09 Nov 2009, 08:09 PM
I have a DateTime field in my database that allows nulls. When I bring the records up to the UI, they come up as DateTime? properties on an object. I have put "=Fields.<DateField>.Value" in the Textbox.Value, but when displaying the report, the textbox shows an error that '.Value' is not valid.
I would like to put =Iif(Fields.DateField.HasValue,Fields.DateField.Value,""), but cannot get anything to work...
Is something like that allowed?
7 Answers, 1 is accepted
0
Accepted
Hello Kevin,
The available "properties" of a DateTime field are listed in our Data Explorer (see attached screenshot) and as you can see Value is not one of them. If you provide only = Fields.DateField in your textbox it would be shown in the default DateTime format according to your localization settings (e.g. for English culture would show mm/dd/yyyy hh:mm:ss) and if you want to format the value you can use the Format Builder Dialog.
Generally handling null values is up to the developer and you can do that either on database level (IS NULL) or using our built in functions IsNull and/or IIF to define a value if null is detected.
Sincerely yours,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The available "properties" of a DateTime field are listed in our Data Explorer (see attached screenshot) and as you can see Value is not one of them. If you provide only = Fields.DateField in your textbox it would be shown in the default DateTime format according to your localization settings (e.g. for English culture would show mm/dd/yyyy hh:mm:ss) and if you want to format the value you can use the Format Builder Dialog.
Generally handling null values is up to the developer and you can do that either on database level (IS NULL) or using our built in functions IsNull and/or IIF to define a value if null is detected.
Sincerely yours,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
kevin floyd
Top achievements
Rank 1
answered on 12 Nov 2009, 05:41 PM
The field in the database allows Null values. As I am using C#, the object that comes up from the database as a Nullable DateTime object ("DateTime?"). Where a normal DateTime object requires a value, a Nullable DateTime object does not require a value. This is being used for various values such as 'ApprovedDate' - if the record was not approved, the value is null.
The IsNull method worked. By using the Expression below, the error did not show when the DateTime was null, and showed the date when it was populated.
{IsNull(Fields.ApprovedDate, "")}
Thanks!
0
sam varg
Top achievements
Rank 1
answered on 08 Mar 2010, 04:26 PM
I have the same situation.
I am using the date filed to display as
I am using the date filed to display as
this
.textBox1.Value = "= Fields.BirthDate";
so how could I check the Isnull?
thanks
sam
0
Hello sam varg,
As my colleague had explained in the previous post you can use our built in functions IsNull and/or IIF to define a value if null is detected.
The following code snipped demonstrates how to use our built in functions:
All the best,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
As my colleague had explained in the previous post you can use our built in functions IsNull and/or IIF to define a value if null is detected.
The following code snipped demonstrates how to use our built in functions:
textBox1.Value = "= IsNull(Fields.BirthDate, "")";
All the best,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Roman Hammes
Top achievements
Rank 1
answered on 02 Jun 2011, 04:12 PM
I found the proposed solution did not work for a check against a DateTimeOffset.
I wrapped the check in CStr function to convert both to string to allow a check without resorting to a user defined function.
prMinDelDate is a DateTimeOffset. 1/1/1967 is an arbitrary value that cannot occur in the data.
= IIf(
CStr(IsNull(Fields.prMinDelDate, CDate("1/1/1967") ) ) = CStr(CDate("1/1/1967")),
"",
Fields.prMinDelDate
)
I wrapped the check in CStr function to convert both to string to allow a check without resorting to a user defined function.
prMinDelDate is a DateTimeOffset. 1/1/1967 is an arbitrary value that cannot occur in the data.
= IIf(
CStr(IsNull(Fields.prMinDelDate, CDate("1/1/1967") ) ) = CStr(CDate("1/1/1967")),
"",
Fields.prMinDelDate
)
0
Carl
Top achievements
Rank 1
answered on 28 Nov 2011, 10:48 PM
Telerik Reporting 4.1.10.921 exposes the .HasValue and .Value properties of Nullable DateTime Fields. But, it does not support them in its Value expressions. It will still throw a NullReferenceException.
0
Hello Carl,
This problem has been fixed in the Q2 2011 SP1 release, namely Fixed: Data Explorer and Expression Editor display incorrectly the properties of nullable fields.
Best wishes,
Steve
the Telerik team
This problem has been fixed in the Q2 2011 SP1 release, namely Fixed: Data Explorer and Expression Editor display incorrectly the properties of nullable fields.
Best wishes,
Steve
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!