使用C#做了一个简单的GridView翻页的例子。
 
前台代码:
InBlock.gif<%@ Page Language= "C#" AutoEventWireup= "true" CodeBehind= "Default.aspx.cs" Inherits= "WebAppGridView._Default" %>
InBlock.gif
InBlock.gif<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
InBlock.gif<html xmlns="http://www.w3.org/1999/xhtml">
InBlock.gif<head runat="server">
InBlock.gif  <title></title>
InBlock.gif</head>
InBlock.gif<body>
InBlock.gif  <form id="form1" runat="server">
InBlock.gif  <div>
InBlock.gif    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
InBlock.gif      OnPageIndexChanging="GridView1_PageIndexChanging">
InBlock.gif      <Columns>
InBlock.gif        <asp:BoundField DataField="A" HeaderText="A" />
InBlock.gif        <asp:BoundField DataField="B" HeaderText="B" />
InBlock.gif        <asp:BoundField DataField="C" HeaderText="C" />
InBlock.gif      </Columns>
InBlock.gif    </asp:GridView>
InBlock.gif  </div>
InBlock.gif  </form>
InBlock.gif</body>
InBlock.gif</html>
 
后台代码:
InBlock.gif public partial class _Default : System.Web.UI.Page
InBlock.gif{
InBlock.gif   protected void Page_Load( object sender, EventArgs e)
InBlock.gif  {
InBlock.gif
InBlock.gif     //----------------------------------------------------------
InBlock.gif     // CREATE TABLE
InBlock.gif     //----------------------------------------------------------
InBlock.gif    DataTable dt = new DataTable();
InBlock.gif    dt.Columns.Add( "A", System.Type.GetType( "System.String"));
InBlock.gif    dt.Columns.Add( "B", System.Type.GetType( "System.String"));
InBlock.gif    dt.Columns.Add( "C", System.Type.GetType( "System.String"));
InBlock.gif
InBlock.gif     //----------------------------------------------------------
InBlock.gif     // SET DATA
InBlock.gif     //----------------------------------------------------------
InBlock.gif     for ( int i = 0; i < 100; i++)
InBlock.gif    {
InBlock.gif      DataRow dr = dt.NewRow();
InBlock.gif      dr[ "A"] = "A" + i.ToString();
InBlock.gif      dr[ "B"] = "B" + i.ToString();
InBlock.gif      dr[ "C"] = "C" + i.ToString();
InBlock.gif      dt.Rows.Add(dr);
InBlock.gif    }
InBlock.gif    
InBlock.gif     this.GridView1.DataSource = dt.DefaultView;
InBlock.gif     this.GridView1.DataBind();
InBlock.gif  }
InBlock.gif
InBlock.gif   protected void GridView1_PageIndexChanging( object sender, GridViewPageEventArgs e)
InBlock.gif  {
InBlock.gif    GridView1.PageIndex = e.NewPageIndex;
InBlock.gif    GridView1.DataBind();
InBlock.gif  }
InBlock.gif}