datagrid绑定错误,如果多个数据绑定到一个datagrid上面就会在分页时就会出现错误。DataGrid的页码超出问题,

//**************************Error********************************

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.

Source Error: 

//***************************************************************

该怎么摆平这种错误呢?

public void GridBind() 

datagrid.DataSource=Con_link(); //这里是要邦定的数据
try

  datagird.DataBind(); 

catch//下面一堆,页数是否超出范围,进行处理。
{   
   int i=LinkShow.CurrentPageIndex; 
   while (i>=LinkShow.PageCount) 
   i--; 
   LinkShow.CurrentPageIndex=i; 
   LinkShow.DataBind();