DateTime - Datagrid

  • Thread starter Thread starter Paul Say
  • Start date Start date
P

Paul Say

I have a class called Job, that has several properties
JobID,Description & StartDate.

The StartDate is Property is defined as follows

public Class Job
private _StartDate as DateTime
public property StartDate() as DateTime
get
return _StartDate
end get
set
_StartDate = value
end set
end property
end class

The problem is when the start date is retreived and displayed in a
datagrid for example, if it has a value of Null(Nothing) the property
returns the value 1/01/0001, is there anyway to return a null value.
 
Paul Say said:
I have a class called Job, that has several properties
JobID,Description & StartDate.

The StartDate is Property is defined as follows

public Class Job
private _StartDate as DateTime
public property StartDate() as DateTime
get
return _StartDate
end get
set
_StartDate = value
end set
end property
end class

The problem is when the start date is retreived and displayed in a
datagrid for example, if it has a value of Null(Nothing) the property
returns the value 1/01/0001, is there anyway to return a null value.

Try:
If _StartDate = DateTime.MinValue Then
Return Nothing
Else
Return _StartDate
End If
 
This didn't work 1/01/0001 is still displayed in the datagrid, I think this
is because the property is returning a value of datatype datetime and when a
datetime type is of value nothing the value is 1/01/0001
 
Paul,

How about using a STRING type in the datagrid instead of a DATE type.
In your get property function you can check to see if the value is null or
not. If its null, send back blanks or whatever you want. If its valid,
send the date value back as a string.

Mike
 
Back
Top