Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/06/2007, 08:57
CrepuX
 
Fecha de Ingreso: mayo-2007
Mensajes: 35
Antigüedad: 17 años
Puntos: 0
Re: MessageBox en Datagrid asp.net

Ya está solucionado para quien le pueda servir.

El tema es que en el DeleteCommand lo que hacemos es simplemente mostrar el mensaje y asignar al selectedIndex del Datagrid el e.Item.ItemIndex.

Después en el YesChoosed, hacemos el tratamiento de borrado del elemento del Datagrid.

Os pongo el código, que se verá más claro:
--------------------------------------------------------------------------
Private Sub dtgGestion_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles dtgGestion.DeleteCommand

MsgBox1.ShowConfirmation("Está a punto de eliminar un Decanato. Desea seguir con la operación??", "Eliminar", True, True)
dtgGestion.SelectedIndex = e.Item.ItemIndex
End Sub

--------------------------------------------------------------------------
Private Sub MsgBox1_YesChoosed(ByVal sender As Object, ByVal Key As String) Handles MsgBox1.YesChoosed
'Key contiene la clave introducida cuando se llama al método ShowConfirmation.
Dim e As System.Web.UI.WebControls.DataGridCommandEventArgs

Select Case Key

Case Key
If Session("decanato_Global").borrar_decanato(ColDec. Item(dtgGestion.CurrentPageIndex * dtgGestion.PageSize + dtgGestion.SelectedIndex + 1).getDecanato()) Then
ColDec.Remove(dtgGestion.CurrentPageIndex * dtgGestion.PageSize + dtgGestion.SelectedIndex + 1)
dtgGestion.SelectedIndex = -1
CargarDecanatos()
Else
Response.Write("<script language=javascript>alert('El decanato no puede ser borrado porque tiene actualmente información dependiente.');</script>")
End If


End Select
--------------------------------------------------------------------------
Private Sub MsgBox1_NoChoosed(ByVal sender As Object, ByVal Key As String) Handles MsgBox1.NoChoosed

Select Case Key
Case "Eliminar"
MsgBox1.ShowMessage("Operación Cancelada.")
End Select
End Sub
--------------------------------------------------------------------------

Un saludo.