2011-02-02 2 views
2

나는 다음과 같은 코드 숨김 코드를 사용하여의 GridView에 대한 온 클릭 동작을 코드하기 위해 노력하고있어 사용 후 System.FormatException 받기 SelectProcess가 CommandName으로 전달 되었기 때문에 그 코드 내에서 수행하려는 작업이 무엇이든 작동하지만 이후에는 다음 오류가 발생하면 프로그램이 작동을 멈 춥니 다.ClientScript

System.Web.HttpUnhandledException (0x80004005): Eine Ausnahme vom Typ "System.Web.HttpUnhandledException" wurde ausgelöst. ---> System.FormatException: Input string was not in a correct format. 
    bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) 
    bei System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) 
    bei System.Convert.ToInt32(String value, IFormatProvider provider) 
    bei System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) 
    bei System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) 
    bei System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) 
    bei System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) 
    bei System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) 
    bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
    bei System.Web.UI.Page.HandleError(Exception e) 
    bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
    bei System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
    bei System.Web.UI.Page.ProcessRequest() 
    bei System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 
    bei System.Web.UI.Page.ProcessRequest(HttpContext context) 
    bei ASP.processes_aspx.ProcessRequest(HttpContext context) in c:\Users\roett04\AppData\Local\Temp\Temporary ASP.NET Files\root\4c906b5d\4377a67f\App_Web_qcvmvpfq.0.cs:Zeile 0. 
    bei System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    bei System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

SelectButton을 추가하고 render-method를 재정의하고 onclick-handler를 추가하기 위해 rowdatabound를 사용하는 대신 OnSelectedIndexChanging을 사용하면 동일한 코드가 제대로 작동합니다.

+0

당신은'if' 라인에서 예외가 발생한다고 말합니다. –

+0

아니요, 코드가 완벽하게 실행되었지만, 프레디 릭이 방금 내가 찾던 답을 게시했습니다! –

답변

2

컨트롤은 페이지 번호로 CommandArgument 이벤트의 속성을 사용할 수있는 Page 명령을 지원합니다. 이 속성을 변환하는 동안 오류가 발생한 것 같습니다.

if 블록의 e.CommandArgument외부에 블록을 할당 하시겠습니까? 이 경우, SelectProcess 이외의 명령에 영향을주기 때문에 수행하지 않아야합니다.

+0

뛰어난, 트릭을 했어, 고마워! CommandArgument를 GridView 내에서 TextValue로 설정하여 다른 명령에 영향을 줄 수 있는지 모릅니다. –

+0

동일한 문제가 발생하지만 e.commandArgument를 어디에도 설정하지 않습니다 - 아이디어가 있습니까? – scouserider

관련 문제