I am facing one problem in c# datetime i have trying more than time. it\'s not giving a problem solution. so give me one solution.
var accommodationcategoryList
Try this:
if(item.logout.HasValue) {
item.logoutTime = item.logout.Value;
}
You're trying to check if a conversion against the null object is null rather than checking the nullable object itself. You need to change this line:
item.logoutTime = (item.logout.Value.ToShortDateString() != null) ? item.logout.Value.ToShortDateString() : "-";
to
item.logoutTime = item.logout.HasValue ? item.logout.Value.ToShortDateString() : "-";