- 在线时间
- 1 小时
- 信用度
- 11
- 最后登录
- 2019-2-11
- 注册时间
- 2007-4-24
- 精华
- 0
- 阅读权限
- 10
- UID
- 315
|
2楼
发表于 2007-4-24 10:12:55
7.错误检测
数据更新后控件调用的事件GridView.RowUpdated,DetailsView.ItemUpdated,SqlDataSource.Updated, etc.
处理“status”的事件,无论数据库是否异常允许数据库异常被处理或者再次抛弃,显示多少数据库行被修改
处理更新错误
<asp:SqlDataSourceID="Employees" RunAt="server"
UpdateCommand="" OnUpdated="OnUpdateComplete">
</asp:SqlDataSource>
void OnUpdateComplete (Object source, SqlDataSourceStatusEventsArgse)
{
if (e.Exception!= null) {
// Exception thrown. Set e.ExceptionHandledto true to prevent
// the SqlDataSourcefrom throwing an exception, or leave it set
// to false to allow SqlDataSourceto rethrowthe exception
}
else if (e.AffectedRows== 0) {
// No exception was thrown, but no records were updated,either.
// Might want to let the user know that the update failed
}
} |
|