Foros del Web » Programación para mayores de 30 ;) » .NET »

Refresco de datagrid

Estas en el tema de Refresco de datagrid en el foro de .NET en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 24/02/2005, 05:34
 
Fecha de Ingreso: febrero-2005
Mensajes: 18
Antigüedad: 19 años, 2 meses
Puntos: 0
Refresco de datagrid

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
  #2 (permalink)  
Antiguo 24/02/2005, 06:11
 
Fecha de Ingreso: octubre-2004
Mensajes: 878
Antigüedad: 19 años, 6 meses
Puntos: 1
Mete el codigo de cargar datagrid en el load solo lo tienes que hacer si not ispostback.
En los demas casos pillalo de la session. Y en los casos de guardar modificar... justo despues de hacerlo haces un recargarDatagrid.


Foros de hiphop
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:53.