Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid, empty date: How show nothing for date value - now shows 1/1/0001??

Reply
Thread Tools

Datagrid, empty date: How show nothing for date value - now shows 1/1/0001??

 
 
=?Utf-8?B?UmV6YQ==?=
Guest
Posts: n/a
 
      02-27-2004
Hi

I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the problem is I guess the datetime variables have a default value. Thus shows an undesirable value of 1/1/0001

How do I go about not showing anything when the value is null like this

Thanks in advance
Reza
 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      02-27-2004
are you sure they are nulls or just empty data fields. (In my experience
"nulls" crash things if you haven't specifically coded around them) Either
way, you should be able to define a function that you can put in your
databinding syntax <%# %> or in your itemdatabound event that will give you
the date you want. Your function would be something like this.

Private Function getDate(ByVal myDate As Object) As String
getDate = CStr(myDate)

If getDate = "1/1/0001" Then
getDate = String.Empty
End If

Return getDate
End Function

then in your datagrid, define a templatecolumn for this column
<asp:templatecolumn headertext="Date">
<itemtemplate>
<%# getDate(DataBinder.Eval(Container.DataItem, "myDate")) %>
</itemtemplate>
</asp:templatecolumn>

hope this helps
--Michael

"Reza" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a column in my datagrid that can have values of null at times. I am

not assigning any value to it, if it is coming from Database empty. Now, the
problem is I guess the datetime variables have a default value. Thus shows
an undesirable value of 1/1/0001.
>
> How do I go about not showing anything when the value is null like this?
>
> Thanks in advance,
> Reza



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re module: Nothing to repeat, but no sre_constants.error: nothing torepeat ? Devin Jeanpierre Python 2 02-14-2012 01:33 PM
A System Tray Issue ( For some reason nothing but the date shows up in my system tray) Jer Computer Support 7 01-28-2007 07:48 AM
Session var in page_load shows old value, buttonclick shows new . Whats wrong gce ASP .Net 0 05-07-2005 06:50 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
show cluster candidates shows nothing Joel M. Baldwin Cisco 2 02-23-2004 09:46 PM



Advertisments