473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DateTime - Datagrid

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.
Nov 18 '05 #1
3 1919
Jos
"Paul Say" <sa****@tpg.com.au> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

--

Jos
Nov 18 '05 #2
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
"Jos" <jo***************@fastmail.fm> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
"Paul Say" <sa****@tpg.com.au> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

--

Jos

Nov 18 '05 #3
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
"Paul Say" <sa****@tpg.com.au> wrote in message
news:up**************@TK2MSFTNGP09.phx.gbl...
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
"Jos" <jo***************@fastmail.fm> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
"Paul Say" <sa****@tpg.com.au> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

--

Jos


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marcos Rodríguez | last post by:
Hi all I have an Access Data Base containing a table which have a DateTime Field. I am creating a Windows App and I am using a DataGrid object to show data from the table using a DataSet object. My...
2
by: A Programmer | last post by:
I can't believe I have never run into this before but, I have an object that has a property of type DateTime. A collection of these objects are used to populate my DataGrid. In DateTime format they...
2
by: Marco Martin | last post by:
Hi all, I've got a DataTable that has a datetime column that is bound to a datagrid. The Datetime Column holds both Date *and* time, but my Datagrid only shows the date. How would I go about...
3
by: Jim H | last post by:
I have a DataGrid where the DataSource is a DataTable that has a DateTime column. Right now it only shows the Date, I want the date and time down to the seconds or better. How do I set the...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
3
by: Paul Say | last post by:
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...
2
by: Tim::.. | last post by:
Hi I'm trying to create a pager that allows you to show records by year and month! I am getting close but would really appritiate some help! Can someone please tell me how I convert the value of...
0
by: Chia Lee Lee | last post by:
Hi, I try to bind records into datagrid based on certain condition.The condition is when the Rdate in database column is larger than today date will be display on datagrid. my problem is , the...
1
mafaisal
by: mafaisal | last post by:
Hello Experts I am Using vb.net 2005 Hw To Put DateTime Picker in Datagrid view I have to sea Datetime Picker in Specified Cilomn of Datagrid I try This But The Location Hw To Change to the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.