I want to check if Date is null then display a string . if not null display date.
<asp:Label ID="Label9" runat="server" Text='<%# Convert.ToDateTime(Eval("Issue_Date")).ToShortDateString() %>' />
Create a method in the code-behind:
public string DisplayDateTime(object value)
{
if (value== null)
{
return "Date is null";
}
return Convert.ToDateTime(value).ToShortDateString();
}
then call DisplayDateTime from a page:
<asp:Label Text='<%# DisplayDateTime(Eval("Issue_Date")) %>' runat="server"></asp:Label>