Skip to main content

ASPxClientGridView.GotoPage(pageIndex) Method

Selects the specified page.

Declaration

GotoPage(
    pageIndex: number
): void

Parameters

Name Type Description
pageIndex number

The active page’s index.

Remarks

Use the GotoPage method to switch between pages in code. End-users can do this via the Pager.

Example

You can totally emulate the pager functionality in a grid template by using the Ajax grid methods.

<%-- BeginRegion TagPrefix and page properties --%>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Grid_ColumnResizing_OverflowHidden_DataItemTemplate" %>
<%@ Register Assembly="DevExpress.Web.v13.1" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1" Namespace="DevExpress.Web.ASPxGridView"  TagPrefix="dx" %>

<%-- EndRegion --%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Create the custom pager in the status bar template</title>    
</head>
<body>
    <form id="form1" runat="server">

    <dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSource1" KeyFieldName="CustomerID" Width="100%" OnCustomCallback="grid_CustomCallback">
        <%-- BeginRegion Grid Columns --%>
        <Columns>
            <dx:GridViewDataColumn FieldName="ContactName" VisibleIndex="0">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="CompanyName" VisibleIndex="1">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="City" VisibleIndex="2">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="Region" VisibleIndex="3">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="Country" VisibleIndex="4">
            </dx:GridViewDataColumn>
        </Columns>
        <%-- EndRegion --%>
        <Settings ShowStatusBar="Visible"  />
        <SettingsPager Visible="false" />
        <Templates>
            <StatusBar>
            <div style="text-align:right;">
                Records per page: 
                <select onchange="window.grid.PerformCallback(this.value);" >
                    <option value="5" <%# WriteSelectedIndex(5) %> >5</option>
                    <option value="10"<%# WriteSelectedIndex(10) %>  >10</option>
                    <option value="15" <%# WriteSelectedIndex(15) %> >15</option>
                    <option value="20" <%# WriteSelectedIndex(20) %> >20</option>
                    <option value="25" <%# WriteSelectedIndex(25) %> >25</option>
                </select>&nbsp;
                <%#GetShowingOnPage() %>&nbsp;
                 <a title="First" href="JavaScript:grid.GotoPage(0);">&lt;&lt;</a> &nbsp; 
                 <a title="Prev" href="JavaScript:grid.PrevPage();">&lt;</a> &nbsp;
                Page <input type="text" onchange="if(!grid.InCallback())  grid.GotoPage(parseInt(this.value, 10) - 1)" onkeydown="if (event.keyCode == 13) { event.cancelBubble=true; event.returnValue = false; grid.GotoPage(parseInt(this.value, 10) - 1); return false; }" value="<%# grid.PageIndex + 1 %>" style="width:20px" /> of <%# grid.PageCount %> &nbsp;
                 <a title="Next" href="JavaScript:grid.NextPage();">&gt;</a> &nbsp;
                 <a title="Last" href="JavaScript:grid.GotoPage(<%# grid.PageCount - 1 %>);">&gt;&gt;</a> &nbsp; 
            </div>
            </StatusBar>
        </Templates>
    </dx:ASPxGridView>
    <%-- BeginRegion DataSource--%>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
        SelectCommand="SELECT * FROM [Customers]" DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = ?" InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [Customers] SET [CompanyName] = ?, [ContactName] = ?, [ContactTitle] = ?, [Address] = ?, [City] = ?, [Region] = ?, [PostalCode] = ?, [Country] = ?, [Phone] = ?, [Fax] = ? WHERE [CustomerID] = ?">
    </asp:AccessDataSource>
    <%-- EndRegion --%>
    </form>
</body>
</html>
See Also