D
David C
I have a web page field formatted with FormatDateTime(mydate,2) and when the
column is NULL the report shows 1/1/0001
Thanks
David
column is NULL the report shows 1/1/0001
Thanks
David
I have a web page field formatted with FormatDateTime(mydate,2) and when the
column is NULL the report shows 1/1/0001
Thanks
David
HockeyFan said:What I would do, David, is to write a server-side function that takes
an object as input. Pass the datefield to this function. The
function then checks to see if the object is null. If so, the
function should return whatever string you figure you want or even ""
so that nothing prints out for date if the date is null.
If the object isn't null, then cast it to a string and then do
whatever date formatting you need to do, and return this string.
It'll work just fine.
I've done this calling it from server side. I've also done this
client side on other types of data. Here's an example:
Text='<%# Cnote.CaseNoteTypeDescription( DataBinder.Eval(Container,
"DataItem.CnoteType")) %>'
Public Function CaseNoteTypeDescription(ByVal obj As Object) As
String
Dim strReturn As String = String.Empty
Dim strCode As String
If (obj Is Nothing) Then
Return String.Empty
End If
strCode = obj.ToString()
If (strCode = String.Empty) Then
Return String.Empty
End If
If (pCaseNotesTypeCodes Is Nothing) Then
pCaseNotesTypeCodes = New Hashtable
End If
If (pCaseNotesTypeCodes.Contains(strCode)) Then
Return pCaseNotesTypeCodes.Item(strCode)
End If
Dim CnoteType As ComitData.LOOKUP_CASE_NOTE_TYPE
Try
CnoteType =
ComitData.LOOKUP_CASE_NOTE_TYPE.Retrieve(strCode)
Catch ex As Exception
AppErrorLog.Log("CaseNoteType bad", "Case note type is
note listed in the lookup table: " & strCode,
System.Environment.UserName, True)
Return String.Empty
End Try
strReturn = CnoteType.Description + ""
pCaseNotesTypeCodes.Add(strCode, strReturn)
Return strReturn
End Function
I've done this plenty of times. You can call your function from
inside a gridview. You can call it from the text property of a
textbox or a label or whatever control you want. As you can see, by
passing the raw database field in as an object, it wont break if the
data item is null. You can check it safely and format it according to
whatever rules you feel you want.
Good luck.