62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
this.nowpage.Text="1";
bindinvit();
}
}
void bindinvit()
{
int currentpage=Convert.ToInt32(this.nowpage.Text);//将当前页面的页面数复值给currentpage
SqlConnection conn=new SqlConnection("server=.;database=web;uid=sa;pwd=");
SqlDataAdapter asd=new SqlDataAdapter("select * from invit order by sendtime desc",conn);
DataSet ds=new DataSet();
asd.Fill(ds,"invit");
System.Web.UI.WebControls.PagedDataSource pds=new PagedDataSource();
pds.DataSource=ds.Tables["invit"].DefaultView;
pds.AllowPaging=true;
pds.PageSize=8;
pds.CurrentPageIndex=currentpage-1;//当前页的索引号
this.pagecount.Text=pds.PageCount.ToString();//总页数
//
if(currentpage==1)
{
this.LinkButton1.Enabled=false;//第一页
this.LinkButton2.Enabled=false;//上一页
}
else
{
this.LinkButton1.Enabled=true;
this.LinkButton2.Enabled=true;
}
if(currentpage==pds.PageCount)
{
this.LinkButton3.Enabled=false;//下一页
this.LinkButton4.Enabled=false; //最后一页
}
else
{
this.LinkButton3.Enabled=true;
this.LinkButton4.Enabled=true;
}
this.GridView.DataSource=pds;
this.GridView.DataBind();
}