My solution was to add the following pagertemplate:
//***
<PagerTemplate>
<asp:Label ID="Label1" runat="server" Text="Show Rows:" />
<asp
ropDownList CssClass="LetraNormal" ID="RegsPag"
runat="server" AutoPostBack="true"
OnSelectedIndexChanged="RegsPag_SelectedIndexChanged">
<asp:ListItem Value="20" />
<asp:ListItem Value="50" />
<asp:ListItem Value="100" />
</asp
ropDownList>
Page
<asp:TextBox ID="IraPag" runat="server" AutoPostBack="true"
OnTextChanged="IraPag" CssClass="irapag" />
of
<asp:Label ID="lblTotalNumberOfPages" runat="server" />
<asp:Button ID="Button4" runat="server" CommandName="Page"
ToolTip="First Page" CommandArgument="First" CssClass="primero" />
<asp:Button ID="Button1" runat="server" CommandName="Page"
ToolTip="Prev. Page" CommandArgument="Prev" CssClass="anterior" />
<asp:Button ID="Button2" runat="server" CommandName="Page"
ToolTip="Next Page" CommandArgument="Next" CssClass="siguiente" />
<asp:Button ID="Button3" runat="server" CommandName="Page"
ToolTip="Last Page" CommandArgument="Last" CssClass="ultimo" />
</PagerTemplate>
//***
And the following code:
//**
protected void RegsPag_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//CAMBIAR NUMERO DE FILAS A MOSTRAR
//OBTIENE EL NUMERO ELEGIDO
DropDownList _DropDownList = (DropDownList)sender;
//CAMBIA EL PAGESIZE DEL GRID ASIGNANDO EL ELEGIDO
this.gridview1.PageSize =
int.Parse(_DropDownList.SelectedValue);
this.gridview1.PageIndex = 0;
}
protected void gridview1_RowDataBound(object sender,
System.Web.UI.WebControls.GridViewRowEventArgs e)
{
// FORMATEA GRID
if (e.Row.RowType == DataControlRowType.Pager)
{
//ASIGNAMOS VALORES A NUMERO DE PAGINA ACTUAL Y TOTAL
PAGINAS
Label _TotalPags =
(Label)e.Row.FindControl("lblTotalNumberOfPages");
_TotalPags.Text = gridview1.PageCount.ToString();
TextBox _IraPag = (TextBox)e.Row.FindControl("IraPag");
_IraPag.Text = (gridview1.PageIndex + 1).ToString();
//ASIGNA AL DROPDOWNLIST COMO VALOR SELECCIONADO EL
PAGESIZE ACTUAL
DropDownList _DropDownList =
(DropDownList)e.Row.FindControl("RegsPag");
_DropDownList.SelectedValue =
this.gridview1.PageSize.ToString();
}
}
protected void IraPag(object sender, System.EventArgs e)
{
//CAMBIO DE PAGINAS
TextBox txtGoToPage = (TextBox)sender;
int pageNumber;
if (int.TryParse(txtGoToPage.Text.Trim(), out pageNumber)
&& pageNumber > 0 && pageNumber <= this.gridview1.PageCount)
{
this.gridview1.PageIndex = pageNumber - 1;
}
else
{
this.gridview1.PageIndex = 0;
txtGoToPage.Text = "1";
}
}
protected void gridview1_DataBound(object sender, EventArgs e)
{
gridview1.BottomPagerRow.Visible = true;
}
protected void gridview1_PreRender(object sender, EventArgs e)
{
GridView grid = (GridView)sender;
switch (grid.PagerSettings.Position)
{
case PagerPosition.Bottom:
grid.BottomPagerRow.Visible = true;
break;
case PagerPosition.Top:
grid.TopPagerRow.Visible = true;
break;
case PagerPosition.TopAndBottom:
grid.BottomPagerRow.Visible = true;
grid.TopPagerRow.Visible = true;
break;
}
}
//**
I think it's working as I espected.
Now I just need to add a checkbox, to let the user decide if he/she
wants to paginate the result or not.
Regards,
Marcelo.
Alexey Smirnov escribió: