<script runat="server">
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