I wanna pass string like "-" to Crystal Report when DateOfBirth is Null
i am using this code for pass date to crystal report
<pre>.Select(u => new
{
u.EmployeeCode,
u.EmployeeName,
JopName = string.IsNullOrEmpty(u.JopName) ? "-" : u.JopName,
Date_Hiring = u.Date_Hiring.GetValueOrDefault(),
AdministrationName = string.IsNullOrEmpty(u.AdministrationName) ? "-" : u.AdministrationName,
DepartmentName = string.IsNullOrEmpty(u.DepartmentName) ? "-" : u.DepartmentName,
PranchName = string.IsNullOrEmpty(u.PranchName) ? "-" : u.PranchName,
DateOfBirth =Convert.ToString(u.DateOfBirth) == string.Empty ? DateTime.Parse("-") : u.DateOfBirth
})
.ToList();
and this is my Class
<pre>public partial class SR1_Result
{
public int EmployeeCode { get; set; }
public string EmployeeName { get; set; }
public string JopName { get; set; }
public Nullable<System.DateTime> Date_Hiring { get; set; }
public Nullable<double> Nat_Salary { get; set; }
public string AdministrationName { get; set; }
public string DepartmentName { get; set; }
public string PranchName { get; set; }
public string MobilePersonalNo { get; set; }
public string MobileWorkNo { get; set; }
public Nullable<System.DateTime> DateOfBirth { get; set; }
}
What I have tried:
i try pass "-" when the DateOfBirth is Null
using this
DateOfBirth =Convert.ToString(u.DateOfBirth) == string.Empty ? DateTime.Parse("-") : u.DateOfBirth
but get this error
System.FormatException: 'String was not recognized as a valid DateTime.'