protected sub gridview1_rowediting(byval sender as object, byval e as system.web.ui.webcontrols.gridviewediteventargs) ' 用户在只读模式中点击"编辑"按钮的时候引发 response.write("row editing...")
' 如果gridview已经处于编辑模式,就终止编辑操作 if not gridview1.editindex = -1 then e.cancel = true end if end sub
protected sub gridview1_rowupdating(byval sender as object, byval e as system.web.ui.webcontrols.gridviewupdateeventargs) ' 当用户在编辑模式中点击"更新"按钮的时候引发 response.write("gridview: row updating...<br/>")
'此处可以选择终止事件,例如不允许用户更新数据 if user.isinrole("restricted") then e.cancel = true end if end sub
protected sub gridview1_rowupdated(byval sender as object, byval e as system.web.ui.webcontrols.gridviewupdatedeventargs) ' 当更新操作完成所时候引发 response.write("gridview: row updated<br/>")
if not e.exception is nothing then ' 此处可以执行自定义的错误处理,完成之后设置exceptionhandled = true e.exceptionhandled = true end if ' 可以检测更新操作所影响的行数 response.write("<br />affected rows: " & server.htmlencode(e.affectedrows)) end sub
protected sub gridview1_rowcancelingedit(byval sender as object, byval e as system.web.ui.webcontrols.gridviewcancelediteventargs) ' 当用户在编辑模式中点击"取消"按钮的时候引发 response.write("edit canceled") end sub
protected sub sqldatasource1_updated(byval sender as object, byval e as system.web.ui.webcontrols.sqldatasourcestatuseventargs) ' 当更新操作完成之后引发 response.write("sqldatasource: update complete<br />") end sub
protected sub sqldatasource1_updating(byval sender as object, byval e as system.web.ui.webcontrols.sqldatasourcecommandeventargs) ' 调用更新操作的时候引发 response.write("sqldatasource: updating...") end sub </script>
protected sub detailsview1_iteminserting(byval sender as object, byval e as system.web.ui.webcontrols.detailsviewinserteventargs) dim f as fileupload = detailsview1.findcontrol("fileupload1") if f.hasfile then ' 保存文件 end if end sub
protected sub formview1_itemdeleted(byval sender as object, byval e as system.web.ui.webcontrols.formviewdeletedeventargs) if (e.exception is nothing) then ' 删除文件 response.redirect(e.values("albumid")) end if end sub