问题描述
我页面的首页,上页,下页,末页,点击不管用,帮忙看看。usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;usingSystem.Data.OleDb;usingSystem.Text;usingSystem.IO;usingxinyun.classes.bases;namespacexinyun.aspx.maintain.mustread.parentmessage{///<summary>///guestbook_list的摘要说明。///</summary>publicclassparentmg:System.Web.UI.Page{protectedSystem.Web.UI.WebControls.DataGridGonGaoGrid;protectedSystem.Web.UI.WebControls.LinkButtonbtnLast;protectedSystem.Web.UI.WebControls.LinkButtonbtnNext;protectedSystem.Web.UI.WebControls.LinkButtonbtnPrev;protectedSystem.Web.UI.WebControls.LabellblCurrentIndex;protectedSystem.Web.UI.WebControls.LabellblPageCount;protectedSystem.Web.UI.WebControls.LabellblPosition;protectedSystem.Web.UI.WebControls.LabelLabel1;protectedSystem.Web.UI.WebControls.LinkButtonbtnqb;protectedSystem.Web.UI.WebControls.LinkButtonButton1;protectedSystem.Web.UI.WebControls.LinkButtonbtnwhf;protectedSystem.Web.UI.WebControls.LinkButtonbtnFirst;privateOleDbConnectioncn=newOleDbConnection();privatevoidPage_Load(objectsender,System.EventArgse){if(Session["userName"]==null){Response.Write("<scriptlanguage=javascript>alert(网页已超时,请重新登录!);</script>");Response.Redirect("../../Login.aspx");return;}setPosition();btnFirst.Text="首页";btnPrev.Text="上一页";btnNext.Text="下一页";btnLast.Text="末页";OpenDatabase();BinGonGaoGridrid();this.Label1.Visible=true;this.Label1.Text="全部留言";}#regionWeb窗体设计器生成的代码overrideprotectedvoidOnInit(EventArgse){////CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}///<summary>///设计器支持所需的方法-不要使用代码编辑器修改///此方法的内容。///</summary>privatevoidInitializeComponent(){this.btnqb.Click+=newSystem.EventHandler(this.btnqb_Click);this.btnwhf.Click+=newSystem.EventHandler(this.btnwhf_Click);this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);this.Load+=newSystem.EventHandler(this.Page_Load);}#endregionprivatevoidOpenDatabase(){cn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+Server.MapPath("../../../../db/xinyun.mdb");cn.Open();}privatevoidShowStats(){lblCurrentIndex.Text="第"+(GonGaoGrid.CurrentPageIndex+1).ToString()+"页";lblPageCount.Text="共"+GonGaoGrid.PageCount.ToString()+"页";}publicvoidPagerButtonClick(objectsender,EventArgse){stringarg=((LinkButton)sender).CommandArgument.ToString();switch(arg){case"next":if(GonGaoGrid.CurrentPageIndex<(GonGaoGrid.PageCount-1)){GonGaoGrid.CurrentPageIndex+=1;}break;case"prev":if(GonGaoGrid.CurrentPageIndex>0){GonGaoGrid.CurrentPageIndex-=1;}break;case"last":GonGaoGrid.CurrentPageIndex=(GonGaoGrid.PageCount-1);break;default:GonGaoGrid.CurrentPageIndex=System.Convert.ToInt32(arg);break;}BinGonGaoGridrid();ShowStats();}publicvoidBinGonGaoGridrid(){OleDbConnectionmyConnection=cn;DataSetds=newDataSet();OleDbDataAdapteradapter=newOleDbDataAdapter("SELECTid,zuti,name,Addtime,"+"iif([IsReplyed]=true,'是',iif([IsReplyed]=false,'否'))asIsreplyed"+"FROMlybORDERBYAddtimeDESC",myConnection);//OleDbDataAdapteradapter=newOleDbDataAdapter("select(case[IsReplyed]when1then'是'else'否'end)fromlyb",myConnection);adapter.Fill(ds,"Document");GonGaoGrid.DataSource=ds.Tables["Document"].DefaultView;GonGaoGrid.DataBind();Buttonbtn;for(inti=0;i<GonGaoGrid.Items.Count;i++){btn=(Button)GonGaoGrid.Items[i].Cells[6].Controls[0];//删除btn.Attributes.Add("onclick","if(!confirm('是否已确认要删除?一旦删除了该记录,将不可恢复!')){returnfalse;}");btn=(Button)GonGaoGrid.Items[i].FindControl("btnModify");//修改btn.Attributes.Add("onclick","ret=window.showModalDialog('book_look.aspx?type=edit&id="+GonGaoGrid.Items[i].Cells[0].Text+"','','dialogWidth=700px;dialogHeight=455px;dialogLeft=60px;dialogTop=30px;status=no;help=no;resizable=yes');if(ret==null||ret=='false'){returnfalse;}");}ShowStats();}publicvoidGonGaoGrid_Page(objectsender,DataGridPageChangedEventArgse){intstartIndex;startIndex=GonGaoGrid.CurrentPageIndex*GonGaoGrid.PageSize;GonGaoGrid.CurrentPageIndex=e.NewPageIndex;BinGonGaoGridrid();ShowStats();}privatevoidsetPosition(){stringstrPostion="<divstyle="background-color:#99DDDD;height:12px;vertical-align:middle">你目前的位置为:后台维护->家长必读->家长留言<hrnoshade="noshade"size="1"/></div>";this.lblPosition.Text=strPostion;}}
解决方案
解决方案二:
没有逻辑性错误,是不是没有设定分页??
解决方案三:
我刚接触这个,不懂你说的设定分页什么的,你能不能详细点,最好举个例子,谢谢!