AllowCustomPaging和Allowpaging都设为true。
代码如下,应该没有问题啊。但总是显示第一页,翻页按钮不起作用。  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码        If Not Page.IsPostBack Then BindGrid()    End Sub
    Function CreateTable() As ICollection
        Dim cn As OleDb.OleDbConnection
        Dim da As OleDb.OleDbDataAdapter
        Dim ds As DataSet
        Dim sql As String        cn = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("dsn") + Server.MapPath(ConfigurationSettings.AppSettings("DBPATH")))
        cn.Open()
        sql = "select lesson_name,iif(open_flag=1,'√','×') as open_flag2 from lesson"
        da = New OleDb.OleDbDataAdapter(sql, cn)
        ds = New DataSet
        da.Fill(ds, "lesson")        CreateTable = ds.Tables("lesson").DefaultView
        cn.Close()
    End Function    Private Sub BindGrid()
        Dim dv As New DataView
        dv = CreateTable()
        grid.DataSource = dv
        grid.VirtualItemCount = dv.Count
        grid.DataBind()
    End Sub    Sub grid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles grid.PageIndexChanged
        grid.CurrentPageIndex = e.NewPageIndex
        BindGrid()
    End Sub

解决方案 »

  1.   

    建议将AllowCustomPaging设为false试试.
      

  2.   

    1)数据肯定有两页
    2)AllowCustomPaging为true不应该成为问题
      

  3.   

    1)数据肯定有两页
    2)AllowCustomPaging为true不应该成为问题
      

  4.   

    1)数据肯定有两页
    2)AllowCustomPaging为true不应该成为问题
      

  5.   

    用DataView做DataGrid的数据源不需要启用自定义分页(AllowCustomPaging),否则你还得手工设置VirtualItemCount值。
      

  6.   

    to webdiyer(陕北吴旗娃) :
       你说得没错,如果AllowCustomPaging=false,程序正常。
    但是,难道AllowCustomPaging=true不行吗?如果AllowCustomPaging=true,应该怎么修改呢?
      

  7.   

    AllowCustomPaging=false 时
    发生错误
    当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DG1 的 DataGrid 必须设置 VirtualItemCount。