这个按钮里面有一条查询语句,点击查询就报这样的错了:当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DgshowProject 的 DataGrid 必须设置 VirtualItemCount。 麻烦个位了.

解决方案 »

  1.   

    这个问题有可能是你用DataReader这样的只读数据源填充DataGrid造成的,你要么就该变数据源为DataTable,或者就是按照错误提示做,实现定制分页。
      

  2.   

    Dim str As String = "select * from tab where name='"+Text1.text+"'"        Session("searchP") = str
            Dim mycmd As SqlCommand
            mycmd = con.CreateCommand()
            con.Open()
            //Me.DgshowProject.AllowPaging = False
            mycmd.CommandText = str
            Dim result As SqlDataReader
            result = mycmd.ExecuteReader()
            'DgShowCustomer.DataSource = result
            'DataBind()
            If result.HasRows Then
                DgshowProject.DataSource = result
                DgshowProject.DataBind()
            Else
                Response.Write("<script>alert('數據庫中未找到查詢記錄!');</script>")
                Response.Write("<script>window.location.href='ACM_Project_QO.aspx'</script>")
            End If
           // Me.DgshowProject.AllowPaging = True之前用了这个,也没有报错,怎么现在就报这样的错呢?麻烦了