Setting the GridView display for a null date in a view

I wanted to bind a gridview to a datasource connected to a view and kept ending up displaying MinDate for the date fields that were Null in my database.

I couldn’t find a way to fix this as part of the bound field properties. I had to convert it to a template field and do the following:

<asp:Label ID="Label1" runat="server" 
   Text='<%# IIF(DirectCast(Eval("ReleasedDate"),DateTime) = DateTime.MinValue, 
           "" , Eval("ReleasedDate", "{0:d}"))  %>'>
</asp:Label> 

Technorati Tags: ,,