I am trying to reuse the same code that I always used, but now it is facing an error.
I look at various user tables, and there I do this:
DateTime dcdt = (DateTime)u.DateCreated;
DateTime lldt = (DateTime)u.LastLogon;
userRow["DateCreated"] = dcdt.ToShortDateString();
inside the loop. I get an error message:
System.InvalidOperationException: Nullable object must have a value.
The error highlights the line "lldt" , not the "dcdt", which comes first. This is strange in itself. Both of these fields in the allow nulls database are checked. And both of them can be zero or nothing can be zero.
The two values are both listed as DateTime? types through intellisense.
I do not understand why ASP.NET refuses to allow me to print a null value for null dates. If it is empty / null, the logic assumes that ASP.NET should simply not print anything.
? , , null DateTimes, , .