I define this in my class
public DateTime? LineCheckSubmitDateTime { set; get; }
I need to initialize this variable using my gridview
But sometimes i need to leave this value to be null ,But when i leave it it returns 1 / 1 / 0001 12:00:00 AM
so here is my code :
newObj.LineCheckSubmitDateTime = (Convert.ToDateTime(gridViewDetails.GetRowCellValue(rowHandle, "LineCheckSubmitDateTime"))==DateTime.Parse("1 / 1 / 0001 12:00:00 AM") ) ? Convert.ToDateTime(gridViewDetails.GetRowCellValue(rowHandle, "LineCheckSubmitDateTime")):null;
So two questions:
1:this code returns this error :
Severity Code Description Project File Line
Error CS0173 Type of conditional expression cannot be determined because there is no implicit conversion between 'DateTime' and '<null>'
2:do you have better solution?