This is a migrated thread and some comments may be shown as answers.

How do I detect a null Nullable<DateTime> in a textbox?

1 Answer 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Grinden
Top achievements
Rank 1
Grinden asked on 01 Sep 2013, 11:55 PM
Hi,

I'm trying to create a report, with an ObjectDataSource that has a couple Nullable<Datetime> fields. I'm attempting to use these in a textbox.
Here's an example of the sort of expression I'm using:

This report covers the period from {IIf(Fields.ReportConfiguration.StartDate is null, "the beginning of time", Fields.ReportConfiguration.StartDate.Date.ToString("D"))} to {IIf(Fields.ReportConfiguration.EndDate is null, "the end of time", Fields.ReportConfiguration.EndDate.Date.ToString("D"))}.

Both StartDate and EndDate are of type Nullable<DateTime>. If they have both have a value then it works correctly, but if either of them are null then I get an "Object reference not set to an instance of an object" error. Should this work, and if not, how do I do it?

I'm using 2013 Q2 SP1.

Thanks,

Richard

1 Answer, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 02 Sep 2013, 08:45 AM
May be it will work with the IsNull function.

SN
Tags
General Discussions
Asked by
Grinden
Top achievements
Rank 1
Answers by
Squall
Top achievements
Rank 1
Share this question
or