2011-06-15 60 views
0

數據綁定完成後,我將關閉數據綁定事件。 我想捕捉可能發生的任何錯誤,所以我不運行StoredProc「sp_UpdatePrintQueueToPrinted」。如何在DataBound事件之前/之前捕獲錯誤

如何在DataBound事件之前捕獲錯誤?

 protected void ListView1_DataBound(object sender, EventArgs e) 
    { 
     using (GPEntities gpe = new GPEntities()) 
     { 
      gpe.sp_UpdatePrintQueueToPrinted();    
     } 
    } 

回答

1

注意,數據綁定結束時OnDataBound發生。一旦數據綁定開始,就會發生OnDataBinding。

您是否試圖捕捉與實際數據綁定本身有關的錯誤?如果是這樣,請使用try catch語句包裝您的.DataBind()事件。還是有一些其他偶然的錯誤,你作爲數據綁定的結果追蹤?

+0

我明白了你的觀點。是的,我想抓住DataBind()。 – 2011-06-15 17:09:14

0

你可以用它踢...數據綁定= OnDataBinding事件)(數據綁定事件之前)

相關問題