Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

convert 01/01/0001 to empty string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tan - 19 Oct 2005 09:15 GMT
I am using ObjectDataSource bind to DetailView which will contain one of the
column with the value type is date. whenver the value of this column is
empty . then it will be display the date in the format ( 01/01/0001), How
can I convert it to empty string or just string?

Thank you very much

tan
Islamegy® - 19 Oct 2005 10:26 GMT
DateTime type Don't Allow null or empty string.. the only way i found to
workaround this is to convert it to string and check if it's 01/01/0001..
I  did myDatetime Class to do this for me when i use ToString() ,
ToShortDateString(),etc...

>I am using ObjectDataSource bind to DetailView which will contain one of
>the column with the value type is date. whenver the value of this column is
[quoted text clipped - 4 lines]
>
> tan
Sebastian Wojciechowski - 19 Oct 2005 11:07 GMT
create class, inherit from DateTime and overload ToString() method

>I am using ObjectDataSource bind to DetailView which will contain one of
>the column with the value type is date. whenver the value of this column is
[quoted text clipped - 4 lines]
>
> tan
Tan - 19 Oct 2005 11:55 GMT
I can not inherit from DateTime, in .net 2.0 is a sealed class, any
suggestions?
Tan

> create class, inherit from DateTime and overload ToString() method
>
[quoted text clipped - 6 lines]
>>
>> tan
Otis Mukinfus - 20 Oct 2005 02:39 GMT
If you are using .NET 2.0 you can use System.Nullable<T>

Look up System.Nullable in the help file.

>I can not inherit from DateTime, in .net 2.0 is a sealed class, any
>suggestions?
[quoted text clipped - 10 lines]
>>>
>>> tan

Otis
Juan T. Llibre - 20 Oct 2005 04:14 GMT
Isn't it simpler to assume that "01/01/0001" is a default value in the
table in question, and that changing that default value to <null>
would simplify the checking/text assignment task ?

Then, checking for IsDBNull / System.DbNull is simple, or use the faster :

bool isNull = (dr[ordinal]==System.DBNull.Value);

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================

> If you are using .NET 2.0 you can use System.Nullable<T>
> Look up System.Nullable in the help file.

>>I can not inherit from DateTime, in .net 2.0 is a sealed class, any
>>suggestions?
[quoted text clipped - 10 lines]
>>>>
>>>> tan
Juan T. Llibre - 19 Oct 2005 11:22 GMT
Maybe 01/01/0001 is a default value assigned in the table ?

Check the table's design and see if it is a default value.
If it is a default value, change the default value to null or empty.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
>I am using ObjectDataSource bind to DetailView which will contain one of the column with
>the value type is date. whenver the value of this column is empty . then it will be
[quoted text clipped - 4 lines]
>
> tan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.