在报告中有一个字符串日期字段,格式为MM/dd/yyyy。其中一些列可能包含空字符串。排序某个部分时出现问题。我约10小时到telerik报告,所以我可能会失去一些明显的东西。根据Telerik报告可能为空的日期进行排序
我最初试图用这样的表达:
=IIf(Fields.ExpirationDate='', CDate('1/1/1990'), CDate(Fields.ExpirationDate))
这是否看起来是正确的?这引发了一个错误: 处理报告“'时发生错误: 未能比较数组中的两个元素。
------------- InnerException ------------- An error has occured while executing function CDate(). Check InnerException for further information. ------------- InnerException ------------- Exception has been thrown by the target of an invocation. ------------- InnerException ------------- String was not recognized as a valid DateTime.
使用自定义的方法中的另一显影剂建议所以我创建内部的report.cs文件
public DateTime EmptyDateToNow(string expirationDate)
{
DateTime parsed;
if (!DateTime.TryParse(expirationDate, out parsed))
return DateTime.Now;
return parsed;
}
,然后试图与= EmptyDateToNow(Fields.ExpirationDate)
和这将引发调用错误:
An error has occured while processing Report '': Failed to compare two elements in the array. ------------- InnerException ------------- The expression contains undefined function call EmptyDateToNow().