我有一个搜索功能(由我的前任编写),它将日期范围,ID,可用程序作为输入并在GridView中显示结果。该功能在大多数时间都正常工作(我已经测试过),但是对于我的应用程序的用户之一,它提供了此错误消息。我无法自己重现此错误以解决此问题。不知道什么是错的!字符串未被识别为有效日期时间
你们能帮忙吗?
类型'System.Web.HttpUnhandledException'的异常被抛出。 System.FormatException:字符串未被识别为有效的DateTime。 在System.DateTimeParse.Parse(字符串s的DateTimeFormatInfo dtfi,DateTimeStyles样式)
在System.Convert.ToDateTime(字符串值) 在APP_ViewFollowupWorkload.GetFilterString()在d:\ SharedServices \ APP \ ViewFollowupWorkload.aspx.cs:在APP_ViewFollowupWorkload.Page_Load(对象发件人,EventArgs e)在d线1415
:\ SharedServices \ APP \ ViewFollowupWorkload.aspx.cs:线268
在错误帮助(IntPtr的FP,对象O, Object t,EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
在System.Web.UI.Control.LoadRecursive()
在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
在System.Web.UI.Page.HandleError(例外五)
在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
在System.Web.UI.Page.ProcessRequest(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)
在System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.Pro cessRequest(HttpContext上下文)
at ASP.app_viewfollowupworkload_aspx.ProcessRequest(HttpContext context)in c:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files \ root \ bad754dd \ a11f74ff \ App_Web_viewfollowupworkload.aspx.ae7ca9bd .uwyek3vs.0.cs:线0
在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔& completedSynchronously)
这里是生成错误的.cs文件代码:
if (txtDateTo.ToString() != string.Empty)
{
if (txtDateTo.ToString().Length > 2)
strFilter = strFilter + " AND submission_date <= ''" + Convert.ToString(Convert.ToDateTime(txtDateTo.ToString()) + new TimeSpan(1, 0, 0, 0)) + "''";
}
尝试记录日期,并让用户发挥他的魔力。另一种方法是,用try/catch将它包围起来,然后将堆栈+用户输入发送到您的邮件。然后你会在下次发生错误时得到通知,并且你会得到越野车日期。 – mslot 2011-06-10 21:15:24