protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack))
        {
            System.Data.DataTable dt = new System.Data.DataTable("dt_1");
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C");
            dt.Rows.Add(new string[] { "1", "2", "3" });
            dt.Rows.Add(new string[] { "4", "5", "6" });
            dt.Rows.Add(new string[] { "str7", "str8", "str9" });
            dt.Rows.Add(new string[] { "str10", "str11", "str12" });
            dt.Rows.Add(new string[] { "str13", "str14", "str15" });
            MyDataGrid.DataSource = dt;
            MyDataGrid.DataBind();
            Session["dt"] = dt;        }
    }protected void Rec_ChangePage(Object sender, DataGridPageChangedEventArgs e)
{
  MyDataGrid.CurrentPageIndex = e.NewPageIndex;
  MyDataGrid.DataSource = Session["dt"];
  MyDataGrid.DataBind();
}

解决方案 »

  1.   

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Page.IsPostBack))
            {
                System.Data.DataTable dt = new System.Data.DataTable("dt_1");
                dt.Columns.Add("A");
                dt.Columns.Add("B");
                dt.Columns.Add("C");
                dt.Rows.Add(new string[] { "1", "2", "3" });
                dt.Rows.Add(new string[] { "4", "5", "6" });
                dt.Rows.Add(new string[] { "str7", "str8", "str9" });
                dt.Rows.Add(new string[] { "str10", "str11", "str12" });
                dt.Rows.Add(new string[] { "str13", "str14", "str15" });
                MyDataGrid.DataSource = dt;
                MyDataGrid.DataBind();
                Session["dt"] = dt;        }
        }
      

  2.   

    GridView有自带的分页功能,不够用吗?
    =========
    楼主问的题目和内容不一样...
      

  3.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
    <form id="Form1" method="Post" runat="server">
        &nbsp;
    <asp:DataGrid id="MyDataGrid"
      OnPageindexChanged="Rec_ChangePage"
      AllowPaging="True"
      PageSize="3"
      runat="server" style="left: 135px; position: absolute; top: 169px" Height="207px" Width="476px">
    <PagerStyle Mode="NumericPages" HorizontalAlign="Center" />
        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
            Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" />
        <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
            Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
    </asp:DataGrid> 
    </form>
    </body>
    </html>