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