This is a migrated thread and some comments may be shown as answers.

Display nothing for 1/1/1900 date

1 Answer 339 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 10 Apr 2012, 04:57 PM
I have a radgrid where I need to display nothing where the data value is 1/1/1900.  It's read only - I don't need a date picker.  Should I use a GridBoundColumn, GridDatetimeColumn, GridTemplateColumn, or other?  How do I trap the values?  I can't change the data source in this case.

1 Answer, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
answered on 11 Apr 2012, 01:39 AM

I ended up going with a template column and a function.  Is this a smart approach or is there a better way to go?

Column...
<telerik:GridTemplateColumn DataField="Response_Date" CurrentFilterFunction="Contains"
DataType="System.DateTime" HeaderText="Response Date"
SortExpression="Response_Date"
UniqueName="Response_Date"><Itemtemplate>
<%#fixDate(DataBinder.Eval(Container.DataItem, "Response_Date"))%></Itemtemplate>
</telerik:GridTemplateColumn>)

Function...
Public Function fixDate(ByVal theDate As Object) As Object
If Not TypeOf theDate Is System.DBNull Then
fixDate = theDate.ToShortDateString
Else
fixDate = String.Empty
        End If
If fixDate = "1/1/1900" Then
fixDate = String.Empty
End If
Return fixDate
End Function
Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Stephen
Top achievements
Rank 1
Share this question
or