473,832 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTime - Datagrid

I have a class called Job, that has several properties
JobID,Descripti on & 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 1957
Jos
"Paul Say" <sa****@tpg.com .au> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I have a class called Job, that has several properties
JobID,Descripti on & 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.MinVal ue 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******** ********@TK2MSF TNGP10.phx.gbl. ..
"Paul Say" <sa****@tpg.com .au> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I have a class called Job, that has several properties
JobID,Descripti on & 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.MinVal ue 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******** ******@TK2MSFTN GP09.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******** ********@TK2MSF TNGP10.phx.gbl. ..
"Paul Say" <sa****@tpg.com .au> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I have a class called Job, that has several properties
JobID,Descripti on & 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.MinVal ue 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
1477
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 problem is that the column showing the DateTime field shows the data with the format dd/MM/yyyy but I want to show the format dd/MM/yyyy HH/mm The Field on the DataBase is defined as DateTime with the format dd/MM/yyyy HH:mm. Also I have created the...
2
7804
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 display the date AND the time, I don't need nor want the time just the date. If I format at any point to a ShortDate I have to convert the type to a string which when applied to the grid interferes with sorting. Is there any way to keep the...
2
3780
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 getting it to display both Date *and* time? regards, Marco
3
1669
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 DataGrid to display the DateTime value in the format I want. DateTime.ToString("MM/dd/yyy hh:mm:ss:fff") Thanks, jim
3
4240
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 datatable feeding the datagrid control. Both are of the DateTime Type. How do I get the time field to display only the Time, and not the date, which is apparently the default.
3
411
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 property StartDate() as DateTime get return _StartDate
2
1379
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 (i) into a date so that l.Text shows the date as Feb or Mar etc etc EG: If i = 1
0
1213
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 records display is not fullil the condition i set. as long as the day value(dd) (RDate) is larger than today day value(dd), it will display on datagrid.It ingore the Month and Year.It seen look like it compare as string instead of dateTime. The...
1
3834
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 column location or In DatagridView any Datetime Picker like DataGridViewComboBoxColumn,DataGridViewCheckBoxColumn etc..?
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10780
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9319
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5623
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4420
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.