protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)//首次进行该页时,页面初始化
{
RecordsCount = GetRecordsCount("default");//默认信息总数
PagesCount = RecordsCount / PAGESIZE + OverPage();//默认的页总数
ViewState["PagesCount"] = RecordsCount / PAGESIZE - ModPage();//保存末页索引,比页总数小1
ViewState["PageIndex"] = 0;//保存页面初始索引从0开始
ViewState["JumpPages"] = PagesCount;
//保存页总数,跳页时判断用户输入数是否超出页码范围
//显示lbPageCount、lbRecordCount的状态
lbPageCount.Text = PagesCount.ToString();
lbRecordCount.Text = RecordsCount.ToString();
//判断跳页文本框失效
if (RecordsCount <= 10)
{
GotoPage.Enabled = false;
}
GridViewDataBind("default");//调用数据绑定函数TDataBind()进行数据绑定运算
}
}
GridView高效分页和搜索功能的实现代码(4)
内容版权声明:除非注明,否则皆为本站原创文章。