473,396 Members | 2,154 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,396 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 1924
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.