DataGrid实现自定义分页
2006-07-01 09:54
344 查看
把DataGrid的AllowPaging和AllowCustomPaging 都设置为true;
private const int PAGE_SIZE = 5; //每页5个记录
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if ( !IsPostBack )
{
int recordCount = 0;
DataGrid1.DataSource = GetData( 0 , PAGE_SIZE , ref recordCount); //得到记录数
DataGrid1.PageSize = PAGE_SIZE;
//不能直接给pagecount赋值,因为它是只读的,VirtualItemCount / PageSize 就是页数。
DataGrid1.VirtualItemCount = recordCount;
DataGrid1.CurrentPageIndex = 0;
DataGrid1.DataBind();
}
}
private void gridOrder_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.DataSource = GetData( e.NewPageIndex , PAGE_SIZE , ref recordCount); //得到记录数
// 设置当前的Page序号值
DataGrid1.CurrentPageIndex =e.NewPageIndex;
DataGrid1.DataBind();
}
private const int PAGE_SIZE = 5; //每页5个记录
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if ( !IsPostBack )
{
int recordCount = 0;
DataGrid1.DataSource = GetData( 0 , PAGE_SIZE , ref recordCount); //得到记录数
DataGrid1.PageSize = PAGE_SIZE;
//不能直接给pagecount赋值,因为它是只读的,VirtualItemCount / PageSize 就是页数。
DataGrid1.VirtualItemCount = recordCount;
DataGrid1.CurrentPageIndex = 0;
DataGrid1.DataBind();
}
}
private void gridOrder_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.DataSource = GetData( e.NewPageIndex , PAGE_SIZE , ref recordCount); //得到记录数
// 设置当前的Page序号值
DataGrid1.CurrentPageIndex =e.NewPageIndex;
DataGrid1.DataBind();
}
相关文章推荐
- DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- (C#)DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- DataGrid实现自定义分页,轻易实现百万级数据分页
- (C#)DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- (C#)DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- 实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择的check
- (C#)DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中自定义DataGrid分页设置的实现
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中自定义DataGrid分页设置的实现
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- (C#)DataGrid实现自定义分页,鼠标移至变色,删除确认、可编辑,可删除
- 如何在DataGrid 控件中实现自定义分页操作
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页