日期:2014-05-19  浏览次数:20478 次

datagrid 分页,点下一页没反应!
sub   Page_Load(Sender   as   Object,e   as   Eventargs)
              if   not   IsPostBack   then
            BindList()
      end   if
      myDataGrid.PagerStyle.Mode=PagerMode.NextPrev
      myDataGrid.PagerStyle.PrevPageText= "上一页 "
      myDataGrid.PagerStyle.NextPageText= "下一页 "
      BindList()
      end   sub
sub   DataGrid_PageIndexChanged(sender   as   object,e   as       System.Web.UI.WebControls.DataGridPageChangedEventArgs)
             
              myDataGrid.CurrentPageIndex=e.NewPageIndex
              myDataGrid.DataBind()
end   sub
sub   BindList()
              myDataGrid.DataSource=adm.QueryAllAdministrator
              myDataGrid.DataBind()      
      end   sub
这个我的部分代码,运行时能datagrid能显示数据,但点下一页时,就没有反应了,状态栏提示网页有错误!还请各位大哥帮帮忙呀!小弟先谢了!

------解决方案--------------------
状态栏提示网页有错误,这个通常是JavaScript代码有问题,检查一下先
------解决方案--------------------
看下有没有把DataGrid 的AllowPaging属性设置为True
------解决方案--------------------
sub Page_Load(Sender as Object,e as Eventargs)

if not IsPostBack then
BindList()
end if

myDataGrid.PagerStyle.Mode=PagerMode.NextPrev
myDataGrid.PagerStyle.PrevPageText= "上一页 "
myDataGrid.PagerStyle.NextPageText= "下一页 "

end sub

sub DataGrid_PageIndexChanged(sender as object,e as System.Web.UI.WebControls.DataGridPageChangedEventArgs)

myDataGrid.CurrentPageIndex=e.NewPageIndex
BindList()

end sub

sub BindList()
myDataGrid.DataSource=adm.QueryAllAdministrator
myDataGrid.DataBind()
end sub

------解决方案--------------------
sub DataGrid_PageIndexChanged(sender as object,e as System.Web.UI.WebControls.DataGridPageChangedEventArgs)

myDataGrid.CurrentPageIndex=e.NewPageIndex
myDataGrid.DataBind() ‘这里错了,不是databind()方法,应该是你的数据帮定方法BindList(),把myDataGrid.DataBind()应该改成:BindList();
end sub
sub BindList()
myDataGrid.DataSource=adm.QueryAllAdministrator
myDataGrid.DataBind()
end sub

------解决方案--------------------
可能:
1,没有允许分页;
2,数据不够一页;

但是你可以在控件里直接里设置的啊.
------解决方案--------------------
先分页 再绑定