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

Binding: Display null value for DateTime.MinValue

1 Answer 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Pearson
Top achievements
Rank 1
James Pearson asked on 19 Jan 2010, 03:27 PM
I'm binding the RadGrid from a collection of business objects.  Some date/time properties, which are null in the database, are set to DateTime.MinValue.  These display as 01/01/0001 12:00:00 AM in the grid.  What's the recommended approach to displaying these as null value (i.e. no value displays in grid)?

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 19 Jan 2010, 04:51 PM
Hello James,

You could use a GridTemplateColumn to achieve this functionality:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <%# (Eval("Date") == DBNull.Value)?"no date": Eval("Date") %>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Let me know whether this approach is suitable for your scenario.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
James Pearson
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or