DXDateOfBirth.Date
is typed as DateTime?
or a nullable datetime. If you are sure this is always a valid date then use the .GetValueOrDefault()
method.
int age = DateTime.Today.Subtract(DXDateOfBirth.Date.GetValueOrDefault());
If you might not actually have a date then you should first check to see if it is set.
int age = DXDateOfBirth.Date.HasValue ? DateTime.Today.Subtract(DXDateOfBirth.Date.Value) : 0;