handling error in gridview
I had gridview whch bind d开发者_如何学编程atasource and I add edit command to gridview to update data and when updating errors apeared so I want to handle these error in label in row_updated event without asp error
Are you using a data source control? Errors from the database can be handled in the DataSourceControl.Updated event, and even cancel that the error happened. For GridView, I'm not sure its as powerful in that regard; there are certain binding errors you cannot capture, and would need to capture the error via the Page_Error or the Application_Error event... However, if you manually write code to do the update, you can always wrap with a try/catch block...
HTH.
RowUpdated event occurs after the update, if there is an error during the update it will happen before the RowUpdated event fires so you cannot handle the error there. You need to handle the error in the RowUpdating event.
精彩评论