为什么我datagrid.currentpage总是0呢
//计算页数,这也是由于datagrid.pagecount总是0出现逼的我写了一个函数///
public int pcount(int count,int pagesize)
{
int pcount=0;
if(count%pagesize==0)
pcount=count/pagesize;
else
pcount=count/pagesize+1;
return pcount;
}
//页面切换
public void pagechange(string pagemark,DataGrid MyDataGrid,int count,int pagesize)
{
int pcount=this.pcount(count,pagesize);
switch(pagemark)
{
case "first ":
MyDataGrid.CurrentPageIndex=0;
break;
case "next ":
if(MyDataGrid.CurrentPageIndex <pcount-1) MyDataGrid.CurrentPageIndex+=1; break;
case "pre ":
if(MyDataGrid.CurrentPageIndex> 0)
MyDataGrid.CurrentPageIndex-=1;
break;
case "last ":
MyDataGrid.CurrentPageIndex = pcount - 1;
break;
}
}
//page_load中的代码
if(this.Request.QueryString[ "type "]!=null)//其中type既first,next...
{
string type=this.Request.QueryString[ "type "].ToString();
this.pagechange(type,this.DataGrid2,this.DataGrid2.VirtualItemCount,6);
startIndex = this.DataGrid2.CurrentPageIndex * this.DataGrid2.PageSize;
this.BindGrid();
}
else
{
this.BindGrid();
}
------解决方案--------------------viewstate禁用了?
------解决方案--------------------还没 遇到过