在datagrid的属性生成器里,选择分页就可以了
事件在datagrid_pageindex里
加代码就可以了。

解决方案 »

  1.   

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridClassAllowCustomPagingTopic.asp
      

  2.   

    Private Sub dgWork_PageIndexChanged(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgWork.PageIndexChanged
            dgWork.CurrentPageIndex = e.NewPageIndex
            dgBind()
        End Sub
      

  3.   

    设置DataGrid允许分页,和每页地记录条数,才能DataGrid中看见翻页
    再PageIndexChange事件中编码
    代码如 下
    MyDataGrid.CurrentPageIndex=e.NewPageIndex;
    MyDataGrid.DataSource=MyDataSet;
    MyDataGrid.DataBind();
      

  4.   

    在datagrid属性生成器中,设置允许分页。
    在PageIndexChange事件中编码:
    MyDataGrid.CurrentPageIndex=e.NewPageIndex;
    MyDataGrid.DataSource=MyDataSet;
    MyDataGrid.DataBind();
      

  5.   

    to  plife(飘摇)   我的 数据源是在 private void Page_Load(object sender, System.EventArgs e){}里面生成的 ,现在的 private void Datgrid_BaseInfo_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e){}
    还可以重新绑定那个数据源吗 ?
      

  6.   

    先择属性生成器->分页->自动分页
      

  7.   

    把pageStyle.Visible = false;再
    在datagrid的下面放一个Panel,Panel上放:“上一页 下一页            GO (文本框)页  共X页,共X条记录”,用函数绑定你要的函数即可
      

  8.   

    xiahouwen(活靶子.NET) 给你的那个地址你没有看啊,那是分页的标准代码啊。
    我抄过来:
    [C#] 
    <%@ Page Language="C#" AutoEventWireup="True" %>
    <%@ Import Namespace="System.Data" %><html>   <script runat="server">      // Normally, an entire data source is loaded in the DataGrid control, 
          // which can take up a lot of resources. This example uses custom 
          // paging, which loads only the segment of data needed to fill a
          // single page. In order to query for the appropriate segment of
          // data, the index of the first item displayed on a page must be
          // tracked as the user navigates between pages.
          int startIndex = 0;      ICollection CreateDataSource() 
          {         // Create sample data for the DataGrid control.
             DataTable dt = new DataTable();
             DataRow dr;         // Define the columns of the table.
             dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
             dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
             dt.Columns.Add(new DataColumn("DateTimeValue", typeof(string)));
             dt.Columns.Add(new DataColumn("BoolValue", typeof(bool)));         // Populate the table with sample values. When using custom paging,
             // a query should only return enough data to fill a single page, 
             // beginning at the start index.
             for (int i = startIndex; i < (startIndex + MyDataGrid.PageSize); i++) 
             {
                 dr = dt.NewRow();             dr[0] = i;
                 dr[1] = "Item " + i.ToString();
                 dr[2] = DateTime.Now.ToShortDateString();
                 dr[3] = (i % 2 != 0) ? true : false;             dt.Rows.Add(dr);
             }         DataView dv = new DataView(dt);
             return dv;      }      void Page_Load(Object sender, EventArgs e) 
          {         // Load sample data only once, when the page is first loaded.
             if (!IsPostBack) 
             {            // Set the virtual item count, which specifies the total number
                // items displayed in the DataGrid control when custom paging
                // is used.
                MyDataGrid.VirtualItemCount = 200;            // Retrieve the segment of data to display on the page from the
                // data source and bind it to the DataGrid control.
                BindGrid();         }      }      void MyDataGrid_Page(Object sender, DataGridPageChangedEventArgs e) 
          {         // For the DataGrid control to navigate to the correct page when
             // paging is allowed, the CurrentPageIndex property must be updated
             // programmatically. This process is usually accomplished in the
             // event-handling method for the PageIndexChanged event.         // Set CurrentPageIndex to the page the user clicked.
             MyDataGrid.CurrentPageIndex = e.NewPageIndex;         // Calculate the index of the first item to display on the page 
             // using the current page index and the page size.
             startIndex = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize;         // Retrieve the segment of data to display on the page from the 
             // data source and bind it to the DataGrid control.
             BindGrid();      }      void BindGrid() 
          {         MyDataGrid.DataSource = CreateDataSource();
             MyDataGrid.DataBind();      }   </script><body>   <form runat="server">
     
          <h3> DataGrid Custom Paging Example </h3>      <asp:DataGrid id="MyDataGrid" 
               AllowCustomPaging="True" 
               AllowPaging="True" 
               PageSize="10" 
               OnPageIndexChanged="MyDataGrid_Page" 
               runat="server">         <HeaderStyle BackColor="Navy" 
                          ForeColor="White" 
                          Font-Bold="True" />         <PagerStyle Mode="NumericPages" 
                         HorizontalAlign="Right" />      </asp:DataGrid>   </form></body>
    </html>
    或者你去文档中心的.net 区 去搜索 “分页”这两个关键字,或者就在本论坛中搜索看看,一般都有你想找的东东
      

  9.   

    试试这个:http://www.webdiyer.com