DataGridView翻页
来源:互联网 发布:win7 软件停止工作 编辑:程序博客网 时间:2024/04/30 15:58
。net翻页很简单,主要解决两个问题,记录当前页,绑定数据。
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtFirstPage_Click(object sender, EventArgs e)
{
lbtNextPage.Enabled = true;
lbtLastPage.Enabled = true;
lbtPreviewPage.Enabled = false;
lbtFirstPage.Enabled = false;
hfCurrentPage.Value = "1";
ddlCurrenPage.SelectedValue = hfCurrentPage.Value;
DBModule dbm = DBModule.Instance();
GridViewLBJ.PageIndex = 0;
GridViewLBJ.DataSource = dbm.DataTableOfLBJ;
GridViewLBJ.DataBind();
}
/// <summary>
/// 前一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtPreviewPage_Click(object sender, EventArgs e)
{
lbtNextPage.Enabled = true;
lbtLastPage.Enabled = true;
int count = Convert.ToInt32(hfCurrentPage.Value);
count--;
hfCurrentPage.Value = count.ToString();
ddlCurrenPage.SelectedValue = hfCurrentPage.Value;
if (count == 1)
{
lbtPreviewPage.Enabled = false;
lbtFirstPage.Enabled = false;
}
DBModule dbm = DBModule.Instance();
GridViewLBJ.PageIndex = count - 1;
GridViewLBJ.DataSource = dbm.DataTableOfLBJ;
GridViewLBJ.DataBind();
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtNextPage_Click(object sender, EventArgs e)
{
lbtPreviewPage.Enabled = true;
lbtFirstPage.Enabled = true;
int count = Convert.ToInt32(hfCurrentPage.Value);
int sumCount = Convert.ToInt32(hfSumPage.Value);
count++;
hfCurrentPage.Value = count.ToString();
ddlCurrenPage.SelectedValue = hfCurrentPage.Value;
if (count == sumCount)
{
lbtNextPage.Enabled = false;
lbtLastPage.Enabled = false;
}
DBModule dbm = DBModule.Instance();
GridViewLBJ.PageIndex = count - 1;
GridViewLBJ.DataSource = dbm.DataTableOfLBJ;
GridViewLBJ.DataBind();
}
/// <summary>
/// 末页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtLastPage_Click(object sender, EventArgs e)
{
lbtPreviewPage.Enabled = true;
lbtFirstPage.Enabled = true;
lbtNextPage.Enabled = false;
lbtLastPage.Enabled = false;
hfCurrentPage.Value = hfSumPage.Value;
ddlCurrenPage.SelectedValue = hfCurrentPage.Value;
DBModule dbm = DBModule.Instance();
GridViewLBJ.PageIndex = Convert.ToInt32(hfSumPage.Value) - 1;
GridViewLBJ.DataSource = dbm.DataTableOfLBJ;
GridViewLBJ.DataBind();
}
- DataGridView翻页
- DataGridView添加翻页功能
- 翻页
- 翻页
- 翻页
- 翻页
- 翻页
- 翻页
- Datagridview
- DataGridView
- DataGridView
- DataGridView
- DATAGRIDVIEW
- DataGridView
- DataGridView
- datagridview
- DataGridView
- dataGridView
- SQL Server Integration Services教程2: 添加循环
- SQL Server Integration Services教程3 :添加包配置
- SQL Server Integration Services教程4: 添加日志记录
- 学习DB2数据库必须掌握的五十四条常用语句
- SQL Server Integration Services教程 5:添加错误流重定向
- DataGridView翻页
- 深入浅出.NET泛型编程
- 自己总结
- 你的简历合适且有意义吗?
- Oracle学习笔记(2)--存储结构
- 求救!
- JButton 设置大小
- 通过sqlldr将文本文件导入到表中
- 数据库基础