aspx_espanol thread: Datagrids, numero de paginas y elemento seleccionado - Resuelto!
Muchas gracias Ismael y Paul, fueron de gran ayuda.
(Tenia problemas con la propiedad IsPostBack en el PageLoad... :)
Ahora la grilla anda al pelo, y selecciona el item de la pagina correcta.
Nuevamente gracias por ocuparse. Hasta pronto, Valeria
----- Original Message -----
From: Ismael iibarra <ismael_ibarra@h...>
To: <valerial@f...>
Sent: Tuesday, March 26, 2002 9:34 PM
Subject: Fwd: [aspx_espanol] Datagrids, numero de paginas y elemento
seleccionado -Helpplease!
> > el codigo para el grid es el siguiente dento de la pagina .aspx, fijate
en
> > OnItemCommand="Botones",
> >
> > <asp:DataGrid id="DataGrid1" runat="server" Width="532px" Height="222px"
> > Visible="true" OnPageIndexChanged="Cambia_Pagina"
OnItemCommand="Botones"
> > PageSize="5" AllowPaging="True" AutoGenerateColumns="False"
> CellPadding="4"
> > BackColor="DarkOrange" BorderColor="#00C0C0" BorderWidth="1px">
> > <FooterStyle ForeColor="White" BackColor="White"></FooterStyle>
> > <HeaderStyle Font-Bold="True" ForeColor="White"
> > BackColor="Teal"></HeaderStyle>
> > <PagerStyle HorizontalAlign="Center" ForeColor="#003399"
> > BackColor="#99CCCC" Mode="NumericPages"></PagerStyle>
> > <SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"
> > BackColor="#C04000"></SelectedItemStyle>
> > <ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
> > <Columns>
> > <asp:BoundColumn Visible="False" DataField="Numero_Emp"
> > HeaderText="Num_Emp"></asp:BoundColumn>
> > <asp:BoundColumn DataField="Nombre"
> > HeaderText="Nombre"></asp:BoundColumn>
> > <asp:BoundColumn Visible="False" DataField="Direccion"
> > HeaderText="Direccion"></asp:BoundColumn>
> > <asp:BoundColumn Visible="False" DataField="Telefono"
> > HeaderText="Telefono"></asp:BoundColumn>
> > <asp:BoundColumn DataField="Nombre_Depto"
> > HeaderText="Departamento"></asp:BoundColumn>
> > <asp:BoundColumn DataField="Pais" HeaderText="Pais
> > Asignado"></asp:BoundColumn>
> > <asp:TemplateColumn>
> > <ItemTemplate>
> > <input type="radio" id="rdo">
> > <asp:Button CausesValidation="False" CommandName="BORRAR"
> > ID="cmdBorrar" Text="Borrar" Runat="server" CssClass="ButtonStyle"
> > Width="70"></asp:Button>
> > <asp:Button CausesValidation="False" CommandName="MODIFICAR"
> > ID="cmdModificar" Text="Modificar" Runat="server" CssClass="ButtonStyle"
> > Width="70"></asp:Button>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> > </Columns>
> > </asp:DataGrid>
> >
> >
> > Ahora en la pagina de Codigo esta el siguiente codigo:
> >
> > Sub Botones(ByVal sender As Object, ByVal e As
> DataGridCommandEventArgs)
> > Try
> > If CType(e.CommandSource, Button).CommandName = "BORRAR"
Then
> > Borrar(e.Item.Cells(0).Text)
> > DataGrid1.CurrentPageIndex
DataGrid1.CurrentPageIndex -
> 1
> > End If
> > If CType(e.CommandSource, Button).CommandName = "MODIFICAR"
> Then
> > CargaDeptos()
> > CargaPais()
> > lblNo_Emp.Text = e.Item.Cells(0).Text
> > txtNombre.Text = e.Item.Cells(1).Text
> > txtDireccion.Text = e.Item.Cells(2).Text
> > txtTelefono.Text = e.Item.Cells(3).Text
> > dpdDepto.Items.FindByText(e.Item.Cells(4).Text).Selected
> > True
> > dpdPais.Items.FindByText(e.Item.Cells(5).Text).Selected
> > True
> > lblAccion.Text = "Modificando"
> > Panel1.Visible = False
> > Panel2.Visible = True
> > End If
> > Catch MyError As Exception
> > End Try
> > End Sub
> >
> >
> > Donde las funciones de CargaDeptos y CargaPais son:
> >
> > Public Sub CargaDeptos()
> > Dim Conexion As cDataBase
> > Dim mydataset As DataSet
> > Conexion = New cDataBase()
> > mydataset = New DataSet()
> > mydataset = Conexion.Deptos
> > dpdDepto.DataSource
mydataset.Tables("Departamento").DefaultView
> > dpdDepto.DataTextField = "Nombre_Depto"
> > dpdDepto.DataValueField = "Numero_Depto"
> > dpdDepto.DataBind()
> > End Sub
> > Public Sub CargaPais()
> > Dim conexion As cDataBase
> > Dim myDataset As DataSet
> > conexion = New cDataBase()
> > myDataset = New DataSet()
> > myDataset = conexion.Pais
> > dpdPais.DataSource = myDataset.Tables("Pais").DefaultView
> > dpdPais.DataTextField = "Pais"
> > dpdPais.DataValueField = "Clave_pais"
> > dpdPais.DataBind()
> > End Sub
> >
> > Es decir carga en dos dropdownlist la informacion.
> >
> > para modificar esos datos
> >
> >
> > >From: "Valeria Lasagna" <valerial@f...>
> > >Reply-To: "ASP.Net en Español" <aspx_espanol@p...>
> > >To: "ASP.Net en Español" <aspx_espanol@p...>
> > >Subject: [aspx_espanol] Datagrids, numero de paginas y elemento
> > >seleccionado -Help please!
> > >Date: Tue, 26 Mar 2002 19:42:17 -0300
> > >
> > >Hola Paul, como estas? Gracias, por contestar!! Sigo liada con esto...
> > >Lo que hice fue pasar a una aspx, lo que me dijiste, pero me encontre
con
> > >el problema que el boton modificar o eliminar no hacen ninguna accion
> > >cuando se los presiona.. Necesito saber, si esta bien invocado el
> > >procedimiento doAction. (Te mando el html y .vb ) y saber por que no
> entra
> > >ahi?
> > >
> > >
> > >Por otro lado me surgio la duda de lo que me escribis despues:
> > >
> > > > en el boton del itemtemplate va un commandName="nombre del boton"
> > > > y en las espesificaciones del grid va un OnItemCommand="mi funcion a
> > > > realizar"
> > >
> > >La funcion a realizar, como llamaste, es el doAction? Si no lo es que
> > >contiene?
> > >Como le paso el nombre del boton y la fila a modificar al DoAction del
> > >OnItemCommand de la grilla?
> > >
> > >Muchas Gracias
> > >Valeria.
> > >
> > ><asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"
> > >AllowPaging="True" PageSize="5" OnPageIndexChanged="MyDataGrid_Page"
> > >OnItemCommand="doAction">
> > ><Columns>
> > > <asp:BoundColumn DataField="GRA_ID"
Visible="true"></asp:BoundColumn>
> > > <asp:BoundColumn DataField="Fecha_Inicio"
> > >HeaderText="Fecha"></asp:BoundColumn>
> > > <asp:TemplateColumn>
> > > <ItemTemplate>
> > > <asp:Button OnItemCommand="mi funcion a realizar"
> > >CausesValidation="False" CommandName="MODIFY" ID="BtnModificar"
> > >Text="Modificar" Runat="server"></asp:Button>
> > > <asp:Button OnItemCommand="mi funcion a realizar"
> > >CausesValidation="False" CommandName="DELETE" ID="BtnBorrar"
> Text="Borrar"
> > >Runat="server"></asp:Button>
> > > </ItemTemplate>
> > > </asp:TemplateColumn>
> > ></Columns>
> > ></asp:DataGrid>
> > >
> > > Mi vb seria:
> > >
> > >Sub mi funcion a realizar ()
> > >
> > > ???????
> > > ??????? (que hace)
> > >
> > >End Sub
> > >
> > >Sub doAction(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
> > > Dim val As Int16
> > > Try
> > > val = e.Item.Cells(0).Text()
> > > If CType(e.CommandSource, Button).CommandName = "MODIFY" Then
> > > 'Modificar(e.Item.Cells(0).Text, e.Item.Cells(1).Text,
> > >e.Item.Cells(2).Text, e.Item.Cells(3).Text, e.Item.Cells(4).Text)
> > > End If
> > > If CType(e.CommandSource, Button).CommandName = "DELETE" Then
> > > 'Borrar(e.Item.Cells(0).Text, e.Item.Cells(1).Text,
> > >e.Item.Cells(2).Text, e.Item.Cells(3).Text, e.Item.Cells(4).Text)
> > > End If
> > > Catch MyError As Exception
> > > End Try
> > >End Sub
> > >
> > >Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As
> > >DataGridPageChangedEventArgs)
> > > Dim sql As String
> > > DataGrid1.CurrentPageIndex = e.NewPageIndex
> > > Session.Add("Pagina", e.NewPageIndex)
> > > sql = "QUERY"
> > > claseOBJ.CargarGrilla(DataGrid1, sql, ConexionSQLClient)
> > >End Sub
> > >
> > >
> > >----- Original Message -----
> > >From: "Paul Zertuche" <jpaulz@h...>
> > >To: <valerial@f...>
> > >Sent: Tuesday, March 26, 2002 2:32 PM
> > >Subject: Re: [aspx_espanol] Datagrids, numero de paginas y elemento
> > >seleccionado -Help please!
> > >
> > >
> > > > Hola como estas???
> > > > pues por ahi va la cosa pero faltan algunas instrucciones!!
> > > >
> > > > en el html el grid quedaria mas o menos asi:
> > > > --------------------------------------------------------------------
> > > > <asp:DataGrid id="Mostrar" runat="server"
AutoGenerateColumns="False"
> > > > AllowPaging="True" PageSize="5" OnPageIndexChanged="cambia_pagina"
> > > > OnItemCommand="doAction">
> > > > <Columns>
> > > > <asp:BoundColumn Visible="False" DataField="Id"
> > > > HeaderText="Id"></asp:BoundColumn>
> > > > <asp:BoundColumn Visible="False" DataField="Zona"
> > > > HeaderText="Zona"></asp:BoundColumn>
> > > > <asp:BoundColumn DataField="Desc"
HeaderText="Desc"></asp:BoundColumn>
> > > > <asp:BoundColumn DataField="Municipio"
> > > > HeaderText="Municipio"></asp:BoundColumn>
> > > > <asp:TemplateColumn>
> > > > <ItemTemplate>
> > > > <asp:Button CausesValidation="False" CommandName="MODIFY"
> > >ID="BtnModificar"
> > > > Text="Modificar" Runat="server"></asp:Button>
> > > > <asp:Button CausesValidation="False" CommandName="DELETE"
> ID="BtnBorrar"
> > > > Text="Borrar" Runat="server"></asp:Button>
> > > > </ItemTemplate>
> > > > </asp:TemplateColumn>
> > > > </Columns>
> > > > <PagerStyle Font-Names="Arial" HorizontalAlign="Center"
> > > > ForeColor="DarkSlateBlue" BackColor="Silver"
> > > > Mode="NumericPages"></PagerStyle>
> > > > </asp:DataGrid>
> > > > --------------------------------------------------------------
> > > > en el boton del itemtemplate va un commandName="nombre del boton"
> > > > y en las espesificaciones del grid va un OnItemCommand="mi funcion a
> > > > realizar"
> > > >
> > > > esto es, cuando tu pulsas un boton en el grid, este envia al
> > >OnItemCommand
> > > > el commandname y los datos de la fila que se envia
> > > > ------------------------------------------------------------------
> > > > en el aspx.vb iria asi:
> > > > -------------------------------------------------------------------
> > > >
> > > > Sub doAction(ByVal sender As Object, ByVal e As
> > >DataGridCommandEventArgs)
> > > > Try
> > > > If CType(e.CommandSource, Button).CommandName = "MODIFY" Then
> > > > Modificar(e.Item.Cells(0).Text, e.Item.Cells(1).Text,
> > > > e.Item.Cells(2).Text, e.Item.Cells(3).Text, e.Item.Cells(4).Text)
> > > > End If
> > > > If CType(e.CommandSource, Button).CommandName = "DELETE" Then
> > > > Borrar(e.Item.Cells(0).Text, e.Item.Cells(1).Text,
> > >e.Item.Cells(2).Text,
> > > > e.Item.Cells(3).Text, e.Item.Cells(4).Text)
> > > > End If
> > > > Catch MyError As Exception
> > > > End Try
> > > > End Sub
> > >
> ---------------------------------------------------------------------
> > > > donde "e.Item.Cells(X).Text" son los datos de la columna subindice X
> que
> > > > seleccionaste en el grid
> > > > los mandas a una funcion, y ahi les das el tratamiento que qieras
> > > > --------------------------------------------------------------------
> > > >
> > > > espero que te sirva
> > > > saludos
> > > > POL
> > > >
> > > > _________________________________________________________________
> > > > Send and receive Hotmail on your mobile device:
http://mobile.msn.com
> > >
> > >
> > >---
> > >Usted está suscrito a aspx_espanol como:
> > >ismael_ibarra@h...
> > >Para darse de baja, envíe un mensaje en blanco a
> > >%%email.unsub%%
> > >
> > >
> > >
> >
> >
> > _________________________________________________________________
> > Con MSN Hotmail súmese al servicio de correo electrónico más grande del
> > mundo. http://www.hotmail.com/ES