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

HELP!!!!!
点击页面上的   上一页等,没有反应,是什么原因?代码如下:
using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.SessionState;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.HtmlControls;
using   System.Data.OleDb;

namespace   loupan
{
///   <summary>
///   morelpan   的摘要说明。
///   </summary>
public   class   morelpan   :   System.Web.UI.Page
{
// protected   System.Web.UI.WebControls.DataGrid   DataGrid1;
protected   System.Web.UI.WebControls.DataGrid   MyDataGrid;

protected   System.Web.UI.WebControls.Label   Label1;
protected   System.Web.UI.WebControls.Label   lblPageCount;
protected   System.Web.UI.WebControls.Label   lblCurrentIndex;
protected   System.Web.UI.WebControls.LinkButton   btnFirst;
protected   System.Web.UI.WebControls.LinkButton   btnPrev;
protected   System.Web.UI.WebControls.LinkButton   btnNext;

protected   System.Web.UI.WebControls.LinkButton   btnLast;

private   OleDbConnection   cn   =   new   OleDbConnection();

// OleDbConnection   myConnection;
// OleDbCommand   myCommand;

private   void   Page_Load(object   sender,   System.EventArgs   e)
{
//   在此处放置用户代码以初始化页面

btnFirst.Text   =   "最首页 ";
btnPrev.Text   =   "前一页 ";
btnNext.Text   =   "下一页 ";
btnLast.Text   =   "最后页 ";

// if(!IsPostBack)
// {
OpenDatabase();
BindGrid();

// }


}

private   void   OpenDatabase()
{
cn.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "
+   HttpContext.Current.Server.MapPath( "lpan.mdb ");
cn.Open();
}
private   void   ShowStats()
{
lblCurrentIndex.Text   =   "第   "   +   (MyDataGrid.CurrentPageIndex   +   1).ToString()   +   "   页 ";
lblPageCount.Text   =   "总共   "   +   MyDataGrid.PageCount.ToString()   +   "   页 ";
}

public   void   PagerButtonClick(object   sender,   EventArgs   e)
{
string   arg   =   ((LinkButton)sender).CommandArgument.ToString();
switch(arg)
{
case   "next ":
if   (MyDataGrid.CurrentPageIndex   <   (MyDataGrid.PageCount   -   1))
{
MyDataGrid.CurrentPageIndex   +=   1;
}
break;
case   "prev ":
if   (MyDataGrid.CurrentPageIndex   >   0)
{
MyDataGrid.CurrentPageIndex   -=   1;
}
break;
case   "last ":
MyDataGrid.CurrentPageIndex   =   (MyDataGrid.PageCount   -   1);
break;
default:
MyDataGrid.CurrentPageIndex   =   System.Convert.ToInt32(arg);
break;
}
BindGrid();
ShowStats();
}
public   void &n