调试了一天了,终于找到问题,应该是微软的bug
值对于 Int32 太大或太小。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.OverflowException: 值对于 Int32 太大或太小。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[OverflowException: 值对于 Int32 太大或太小。]
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +2783653
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +212
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +199
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
我在GridView里自定义了LinkButton的CommandName,CommandArgument的属性,CommandName="select",CommandArgument是我的单据号,类似"20120131001",结果就报上述错误。
最终解决方法,CommandName="select"改为"selec",少一位就可以了,减少CommandArgument的长度也是可以的。
总结:应该是CommandName+CommandArgument的长度有限制,超过后会试图把CommandArgument的string类型转为int32,所以报溢出了。