我在更新面板中放置了一个网格视图。当用户删除将导致 FK 错误的行时,将不会显示任何消息和错误页面,因为 asyncpostback 更新面板。
当 e.AffectedRows=0 时,我放置了一个 ScriptManager.RegisterStartupScript 以在 GridView2_RowDeleted 事件中显示一些消息。但它也不起作用(没有任何反应)。我认为可能在 GridView2_RowDeleted 事件之前发生 SQL 错误。
那么,有人可以给我一些想法吗?我需要的是在发生 SQL 错误时显示警报或 lable.text 之类的消息(更新面板中的网格视图)
现在这里是 GridView2_RowDeleted 的代码
Private Sub GridView2_RowDeleted(sender As Object, e As GridViewDeletedEventArgs) Handles GridView2.RowDeleted
If e.AffectedRows = 0 Then
Label14.Text = "Can't Del because still material in this storage!"
ScriptManager.RegisterStartupScript(Me.UpdatePanel2, Me.UpdatePanel2.GetType(), "mykey", "alert('Error:" & "Can't Del because still material in this storage!" & "');", True)
UpdatePanel2.Update()
End If
End Sub