view to bind data from Data-source and displaying the data in ultrawingrid when the date field is having System.DateTime.MaxValue I need to set a null or empty value in it. I was unable to set it.
Asked
Active
Viewed 595 times
0
-
Why were you unable to set it? What happened, what is your code at all? – Tim Schmelter Dec 04 '15 at 10:42
-
When I am setting it to null its showing an error saying that DateTime fields does not allow null values – chaitanya Phani Dec 04 '15 at 10:45
-
Possible duplicate of [DateTime "null" value](http://stackoverflow.com/questions/221732/datetime-null-value) – Liam Apr 21 '17 at 10:23
1 Answers
1
You can't set DateTime to null. It's value type but not reference type. Like structures, int, double, etc.
You can use Nullable<DateTime>
(the same = DateTime?
).
Or instantiate it with default value var someDateTime = default(DateTime);

Liam
- 27,717
- 28
- 128
- 190

AntonKolesnikov
- 33
- 3
-
But when setting to default its showing System.DateTime.min value – chaitanya Phani Dec 04 '15 at 11:00
-
Only reference type variable could be equal to null. All value-type variables could have only some value like nubmers, dates and so on. Null is not a value, it's like a flag, that referenced value does not specify any reference to value, that's why null could not be applyed to value-type variables. – AntonKolesnikov Dec 04 '15 at 11:05
-
-
Is there any solution to do display null value ?? either by changing the data type ?? – chaitanya Phani Dec 04 '15 at 11:06