|
You can write a code customization to go to a specific page in a table. One way to do this
is to pass the page number on the URL, for example:
|
http://localhost/MyApp/ShowCustomersTable.aspx?page=4
|
Handle the Load event for the Page class and set the CurrentPageIndex to the value passed
via the URL. Then, call the DataBind() method to refresh the page.
C#:
public class ShowCustomersTablePage : BaseShowCustomersTablePage
{
public ShowCustomersTablePage()
{
this.Load += new EventHandler(Page_Load);
}
// Occurs when the server control is loaded on to the Page object.
private void Page_Load(object sender, System.EventArgs e)
{
if (!(this.IsPostBack))
{
If (this.Request.QueryString["page"] != null)
{
this.CustomersTableControl.CurrentPageIndex = _ (int.Parse(this.Request.QueryString["page"])) - 1;
this.DataBind();
}
}
}
} // End class ShowCustomersTablePage
|
Visual Basic .NET:
Private Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (Me.Page.IsPostBack) Then
If Not ((Me.Request.QueryString("page")) Is Nothing) Then
Me.CustomersTableControl.CurrentPageIndex = CInt(Me.Request.QueryString("page")) – 1
Me.DataBind()
End If
End If
End Sub
|
Change the CustomersTableControl to the name of the table control on your page.
Alternatively, you can add a textbox for the user to input the page number. When the user presses the
Go button, execute the same two lines of code in the above function to change the page number.
C#:
this.CustomersTableControl.CurrentPageIndex = this.pageNumberTextBox.text;
this.DataBind();
|
Visual Basic .NET:
Me.CurrentPageIndex = PageNumberTextBox.text
Me.DataBind()
|
|