Go to a Specific Page in a Table Panel

Updated October 20, 2006
Iron Speed Designer V4.0

You can easily write a code customization to go to a specific page in a table panel, such as page 14 of 30.  One way to do this is to pass the page number on the URL, for example:

http://localhost/MyApp1/Orders/ShowOrdersTablePage.aspx?page=14

To implement this mechanism, override the Page_Load_InitPageSettings() method for the Page class and set the PageIndex to the value passed via the URL.  Then, call the DataBind() method to refresh the page.  The example below adds this customization to a Show Table page built using the Orders table in the Northwind database, located in:

...\<App Folder>\Orders\ShowOrdersTablePage.aspx.cs or .vb

The code customization is inserted into the ShowOrdersTablePage class.

C#:

protected override void Page_Load_InitPageSettings(object sender, EventArgs e)

{

     if (!(this.IsPostBack))

     {

          if (this.Request.QueryString["page"] != null)

          {

               this.OrdersTableControl.PageIndex = (int.Parse(this.Request.QueryString["page"])) - 1;

               this.DataBind();

          }

     }

     base.Page_Load_InitPageSettings(sender, e);

}

Visual Basic .NET:

Protected Overrides Sub Page_Load_InitPageSettings(ByVal sender As Object, ByVal e As EventArgs)

     If Not Me.IsPostBack Then

          If (Not (Me.Request.QueryString("page")) Is Nothing) Then

              Me.OrdersTableControl.PageIndex  =  (Integer.Parse(Me.Request.QueryString("page")) - 1)

               Me.DataBind

          End If

     End If

     MyBase.Page_Load_InitPageSettings(sender, e)

End Sub

See Also

Part V: Customizing Generated Application Code