Hola de nuevo, tengo una pagina aspx con el siguiente codigo en el evento load:
Código:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Introducir aquí el código de usuario para inicializar la página
Dim TablaDatos As DataTable
Dim dvVista As DataView
Dim Gestion As ButtonColumn
If (Not IsPostBack) Or (Session("TablaDatos") Is Nothing) Then
TablaDatos = AbrirFicheroUV("MAESMON", "MAESMONWEB", True, "")
Session("TablaDatos") = TablaDatos
Else
TablaDatos = Session("TablaDatos")
End If
If Not TablaDatos Is Nothing Then
dvVista = New DataView(TablaDatos)
If Not Session("OrdenarPor") Is Nothing Then
dvVista.Sort = Session("OrdenarPor")
End If
If PermitirEdicion Then
Gestion = New ButtonColumn
Gestion.CommandName = "editar"
Gestion.Text = "<font color=red>EDITAR</font>"
dgDatos.Columns.Add(Gestion)
End If
If PermitirEliminacion Then
Gestion = New ButtonColumn
Gestion.CommandName = "borrar"
Gestion.Text = "<font color=red>BORRAR</font>"
dgDatos.Columns.Add(Gestion)
End If
dgDatos.DataSource = dvVista
dgDatos.DataBind()
Else
'Se podujo un error al abrir el fichero de datos
Response.Redirect("Error.aspx")
End If
End Sub
En el load lo que hago es cargar el datagrid (dgDatos) con la tabla que necesito mostrar, en la pagina tambien hay un boton de guardar que guarda los datos y que tiene el siguiente codigo:
Código:
Private Sub cbGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbGuardar.Click
Dim MenError As String = ""
Dim EsEdicion As Boolean
Dim Autorizado As String
Dim dvVista As DataView = CType(dgDatos.DataSource, DataView)
If Not Page.IsValid Then
Exit Sub
End If
If Not esEntero(tbCodigo.Text) Then
MenError &= "<LI>El código debe ser un número entero.</LI>"
End If
'Validar denominacion
If Not esNumero(tbSuperficie.Text) Then
MenError &= "<LI>La superficie debe ser númerica.</LI>"
End If
If MenError <> "" Then
lErrores.Text = "<table border=1><tr><td><UL type=square><LH><H3><font color=red>Errores:</font></H3></LH>" & MenError & "</UL></td></tr></table>"
lErrores.Visible = True
Exit Sub
End If
If chbAutorizado.Checked Then
Autorizado = "S"
Else
Autorizado = "N"
End If
Universe = New cUniDK
EsEdicion = ExistePK("MAESMON", RellenarHueco(tbCodigo.Text, "0", 6, False))
GuardarRegUV("MAESMON", _
RellenarHueco(tbCodigo.Text, "0", 6, True), _
tbDenominacion.Text.ToUpper, _
cbProvincia.SelectedValue, _
cbEspecie.SelectedValue, _
Float2FloatUV(tbSuperficie.Text, 2), _
cbProveedor.SelectedValue, _
"", _
"", _
cbTipoObra.SelectedValue, _
"", _
cbDepartamento.SelectedValue, _
cbDelegacion.SelectedValue, _
cbComarca.SelectedValue, _
cbCliente.SelectedValue, _
cbEstado.SelectedValue, _
Autorizado, _
cbCentroNeg.SelectedValue, _
cbGrupoAct.SelectedValue, _
cbActividad.SelectedValue)
If EsEdicion Then
EditScroll("MAESMONWEB", _
RellenarHueco(tbCodigo.Text, "0", 6, True), _
tbDenominacion.Text.ToUpper, _
cbProvincia.SelectedItem.Text.Split("-")(1).Trim, _
cbDelegacion.SelectedItem.Text.Split("-")(1).Trim, _
cbComarca.SelectedItem.Text.Split("-")(1).Trim)
Else
AddScroll("MAESMONWEB", _
RellenarHueco(tbCodigo.Text, "0", 6, True), _
tbDenominacion.Text.ToUpper, _
cbProvincia.SelectedItem.Text.Split("-")(1).Trim, _
cbDelegacion.SelectedItem.Text.Split("-")(1).Trim, _
cbComarca.SelectedItem.Text.Split("-")(1).Trim)
End If
cbLimpiar_Click(sender, e)
End Sub
Haga lo que haga el datagrid no se refresca, he intentado varias cosas en al cbGuardar_Click, como:
1. Session("TablaDatos")=Nothing para forzar la recarga
2. Borrar la fila con cType(Session("TablaDatos"), DataTable).....
pero lo que ocurre es que primero se ejecuta el evento Load (como es natural) y a continuacion el codigo que se encuentra en el evento cbGuardar_Click, con lo que estas instrucciones se ejecutan pero no producen ningun efecto al mostrar la pagina, solo si esta se recarga.
¿Como podria hacerle para que se me actualize el datagrid?
No se si me he explicado bien, si alguien tiene alguna duda se lo reesplico.
Un saludo y muchas gracias