DateTime - Datagrid

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.
 
J

Jos

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
 
P

Paul Say

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
 
M

Mike Johnson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top