第
页/ 共
页
首页
上一页
下一页
尾页
|
protected void GVSample_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
GridView gv = sender as GridView;
if (((Label)e.Row.FindControl("lbCurrentPage")).Text == "1")
{
((LinkButton)e.Row.FindControl("lbtnFirst")).Visible = false;
((LinkButton)e.Row.FindControl("lbtnPrev")).Visible = false;
}
if (((Label)e.Row.FindControl("lbCurrentPage")).Text == ((Label)e.Row.FindControl("lbTotalPage")).Text)
{
((LinkButton)e.Row.FindControl("lbtnNext")).Visible = false;
((LinkButton)e.Row.FindControl("lbtnLast")).Visible = false;
}
DropDownList ddl = ((DropDownList)e.Row.FindControl("ddlPages"));
for (int i = 1; i <= gv.PageCount; i++)
{
ListItem item = new ListItem();
item.Value = i.ToString();
item.Text = i.ToString();
ddl.Items.Add(item);
}
ddl.Items.FindByValue((gv.PageIndex + 1).ToString()).Selected = true;
}
}