Retroceder   Foros del Web > Programación para sitios web > .NET > web forms

Respuesta
 
Herramientas Desplegado
Antiguo 07-abr-2008, 13:26   #1 (permalink)
Rodro ha deshabilitado el karma
 
Fecha de Ingreso: junio-2007
Mensajes: 213
Paginacionn del gridview.

Hola yo tengo un gridview configurada la propiedad PagerSettings con mode "numeric" pero yo tengo bastante registros se me haria más fácil si en lugar de salir la páginacion asi:


1234564789...

me saliera asi:

123456789 Siguiente

Anterior 10 11 12 13 14 15 16 17 18 19 Siguiente

Como yo podría lograr esa paginción?

Gracias.
Rodro está desconectado   Responder Citando
Antiguo 07-abr-2008, 14:42   #2 (permalink)
rcervera67 ha deshabilitado el karma
 
Fecha de Ingreso: noviembre-2007
Ubicación: Trabajo en INEGI
Mensajes: 22
Re: Paginacionn del gridview.

Ok amigo espero te pueda servir este codigo ...


en la parte de html, yo tengo lo siguiete

defino una tabla para los titulos
<table borderColor="#006599" cellSpacing="0" cellPadding="0" width="98%" bgColor="#e7eef5" border="1">
<tr>
<td class="txt_azul_9b" style="BORDER-RIGHT: #e7eef5 1px solid; BORDER-TOP: #006599 1px solid; BORDER-LEFT: #006599 1px solid; BORDER-BOTTOM: #006599 1px solid" align="center" width="14%">Clave</td>
<td class="txt_azul_9b" style="BORDER-RIGHT: #e7eef5 1px solid; BORDER-TOP: #006599 1px solid; BORDER-LEFT: #006599 1px solid; BORDER-BOTTOM: #006599 1px solid" align="left" width="70%">&nbsp;&nbsp;Catálogo de Productos</td>
</table>

<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr >
<td>&nbsp;</td></tr>
<tr><td vAlign="top">
defino un area para poner el grid con scroll
<div style=" BORDER-RIGHT:#006599 1px solid; BORDER-TOP:#006599 1px solid; BORDER-LEFT:#006599 1px solid; BORDER-BOTTOM:#006599 1px solid; WIDTH:99%; HEIGHT:330px; overflow:scroll">
<asp:DataList ID="MyProducto" runat="server" GridLines="None" Width="100%" OnItemDataBound="MyProducto_ItemDataBound" CellPadding="0">
<ItemTemplate>
<table cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<tr>
<td vAlign="top" align="center" width="15%"> <asp:Label CssClass="txt_negro_9" id="upc" runat="server"></asp:Label></td>
<td vAlign="top" align="left" width="81%"> <asp:Label id="titulo" CssClass="txt_negro_9" runat="server"></asp:Label></td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemStyle BackColor="White" HorizontalAlign="Center" VerticalAlign="Top" />
<ItemStyle BackColor="White" HorizontalAlign="Center" VerticalAlign="Top" Wrap="False" />
</asp:DataList>
</div></td>
</tr>
</table>
defino una tabla para encapsular la paginacion personal
<table cellSpacing="0" cellPadding="0" width="100%" align="center" border="0">
<tr>
<td width="45%">&nbsp;</td>
<td width="55%">&nbsp;</td>
</tr>
<tr>
<td class="txt_negro_9b">
defino el area donde voy a crear la paginación
<asp:Panel ID="PanelPaginacion" runat="server" Width="100%"></asp:Panel></td>
<td><asp:Button id="Button1" runat="server" Text="Asignar" ToolTip="Asigna los productos que se encuentran marcados al escaparate de la Tienda Virtual." OnClick="Button1_Click"></asp:Button></td>
</tr>
</table>


utilizo una base de datos sql-server 2005 y genere un procedimiento almacenado para paginar de forma efectiva


@PageNumber int
AS
SELECT
res.RowNumber, res.upc, res.titulo, substring(res.disponibilidad,3,1) as disponibilidad
FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY p.upc ) AS RowNumber,
isnull(p.upc,'000000000000') as upc,
isnull(p.titulo,'nulo') as titulo,
isnull(p.disponibilidad,'00000') as disponibilidad
From esquema.tabla p
Where p.prod_liberado=1 and substring(p.disponibilidad,3,1)=1) AS res
WHERE RowNumber BETWEEN 25 * @PageNumber + 1
AND 25 * (@PageNumber + 1)


el parametro es la pagina que se quiere mostrar y solo regresa 25 registros cada vez

en webconfig

<appSettings>
<add key="PageSize" value="25"/>
</appSettings>


public static readonly int PageSize = Int32.Parse(ConfigurationManager.AppSettings.Get(" PageSize"));

private int TotalRowCount
{
get {
object o = ViewState["TotalRowCount"];
if (o == null)
return -1;
else
return (int)o;
}
set { ViewState["TotalRowCount"] = value; }
}

private int PageCount
{
get {
if (TotalRowCount <= 0 || TotalRowCount <= PageSize)
return 1;
else
return ((TotalRowCount + PageSize) - 1) / PageSize;
}
}

private int PageIndex
{
get {
if (!string.IsNullOrEmpty(Request.QueryString["pageIndex"]))
return Convert.ToInt32(Request.QueryString["pageIndex"]);
else
return 0;
}
}


protected void pintaPaginas(int tope)
{
this.PanelPaginacion.Controls.Clear();
CControles CWeb = new CControles();
if (tope > 10)
{
this.PanelPaginacion.Controls.Add(CWeb.Boton_image n("FirstPage", "~/img/primer.png", urlDestino(0)));
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_blanco_8", "."));
this.PanelPaginacion.Controls.Add(CWeb.Boton_image n("PrevPage", "~/img/antes.png", urlDestino(tope - 11)));
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_blanco_8", "."));
}
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_negro_9", "[ Página "));
for (int i = tope - 9; i <= tope && i <= PageCount; i++)
{
this.PanelPaginacion.Controls.Add(CWeb.Agrega_Link (i.ToString(), "default.aspx?pageIndex=" + i.ToString()));
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_blanco_8", "."));
}
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_negro_9", "de " + PageCount.ToString() + " ]"));
if (tope < PageCount)
{
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_blanco_8", "."));
this.PanelPaginacion.Controls.Add(CWeb.Boton_image n("NextPage", "~/img/siguiente.png", urlDestino(tope + 1)));
this.PanelPaginacion.Controls.Add(CWeb.Agrega_labe l("txt_blanco_8", "."));
this.PanelPaginacion.Controls.Add(CWeb.Boton_image n("LastPage", "~/img/ultimo.png", urlDestino(PageCount)));
}
}



protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
TotalRowCount = (int)SqlHelper.ExecuteScalar(SqlHelper.ConnectionS tringLocalTransaction, CommandType.Text, "Select count(*) From esquema.tabla ", null);

if (this.Page.Request.Params["pageIndex"] == null)
this.MyProducto.DataSource = tbl.GetLN_Admon_TV_pagina(0);
else
this.MyProducto.DataSource = tbl.GetLN_Admon_TV_pagina(this.Page.Request.Params["pageIndex"] );
this.MyProducto.DataBind();
if (PageCount > 1)
this.pintaPaginas(((this.PageIndex / 10) + 1) * 10);
}


espero te sirva
rcervera67 está desconectado   Responder Citando
Antiguo 07-abr-2008, 16:05   #3 (permalink)
Rodro ha deshabilitado el karma
 
Fecha de Ingreso: junio-2007
Mensajes: 213
Re: Paginacionn del gridview.

Gracias por responder amigo, pero noto un poco compleja tu respuesta aún si yo podría intentarlo pero tu control es un DataList y yo tengo un GridView será que no me da problemas.
Con si alguien tiene una opción más sencilla y si es posible desde las propieddaes del gridview bienvenida sea.
Rodro está desconectado   Responder Citando
Antiguo 09-abr-2008, 10:01   #4 (permalink)
Rodro ha deshabilitado el karma
 
Fecha de Ingreso: junio-2007
Mensajes: 213
Re: Paginacionn del gridview.

Nadie más tiene una idea, yo no quiero quitar la paginación numerica del datagrid yo solo quiero además de la numeración dos enlaces anterior y siguiente, no hy forma de lograr eso son tanto cosa?

Anterior 123456789... Siguente

Solo quiero asi que salga en la misma grilla, please ayudenme.
Rodro está desconectado   Responder Citando
Antiguo 09-abr-2008, 12:22   #5 (permalink)
mdavila ha deshabilitado el karma
 
Fecha de Ingreso: julio-2007
Mensajes: 395
Re: Paginacionn del gridview.

Me uno al pedido.....
mdavila está desconectado   Responder Citando
Respuesta
No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 01:15.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93