62,047
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GridView1.Caption = "员工基本信息";
this.GridView1.PagerSettings.Mode = PagerButtons.NextPreviousFirstLast;
this.GridView1.PagerSettings.FirstPageImageUrl = "~/First.gif";
this.GridView1.PagerSettings.LastPageImageUrl = "~/Last.gif";
this.GridView1.PagerSettings.NextPageImageUrl = "~/Next.gif";
this.GridView1.PagerSettings.PreviousPageImageUrl = "~/Previous.gif";
this.GridView1.PageSize = 3;
}
this.GridView1.DataBind();
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridViewRow botomRow = this.GridView1.BottomPagerRow;
Label bottomPagerNo = new Label();
bottomPagerNo.Text = "目前所在的分页码(" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + ")";
botomRow.Cells[0].Controls.Add(bottomPagerNo);
Literal myLiteral = new Literal();
myLiteral.Text = "<br/>";
botomRow.Cells[0].Controls.Add(myLiteral);
for (int i = 0; i < this.GridView1.PageCount; i++)
{
LinkButton PageNo = new LinkButton();
PageNo.Text = Convert.ToString(i + 1);
PageNo.ID = PageNo + i.ToString();
PageNo.CommandArgument = i.ToString();
PageNo.Click += new EventHandler(PageNo_Click);
botomRow.Cells[0].Controls.Add(PageNo);
Literal bland = new Literal();
bland.Text = " ";
botomRow.Cells[0].Controls.Add(bland);
}
}
void PageNo_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = Convert.ToInt16(((LinkButton)sender).CommandArgument);
}