datagrid无法翻页
各位高手帮忙看看,代码如下:
private void BindGrid()
{
SqlConnection conn=new SqlConnection("Persist Security Info=False;database=EXAMP;server=(local);Connect Timeout=10;User=sa;Password=admin;");
conn.Open();
SqlDataAdapter Cmd = new SqlDataAdapter("select * from FillVc ",conn);
DataSet ds=new DataSet();
Cmd.Fill(ds,"FillVc");
DataGrid1.DataSource=ds.Tables["FillVc"].DefaultView;
DataGrid1.DataBind();
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
startIndex=e.NewPageIndex*DataGrid1.PageSize;
DataGrid1.CurrentPageIndex=e.NewPageIndex;
BindGrid();
}
private void InitializeComponent()
{
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
startIndex=0;
}
BindGrid();
}
private void BindGrid()
{
SqlConnection conn=new SqlConnection("Persist Security Info=False;database=EXAMP;server=(local);Connect Timeout=10;User=sa;Password=admin;");
conn.Open();
SqlDataAdapter Cmd = new SqlDataAdapter("select * from FillVc ",conn);
DataSet ds=new DataSet();
Cmd.Fill(ds,"FillVc");
DataGrid1.DataSource=ds.Tables["FillVc"].DefaultView;
DataGrid1.DataBind();
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
startIndex=e.NewPageIndex*DataGrid1.PageSize;
DataGrid1.CurrentPageIndex=e.NewPageIndex;
BindGrid();
}
private void InitializeComponent()
{
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
startIndex=0;
}
BindGrid();
}
...全文
相关推荐
datagrid datagrid-scrollview 列宽不够时,无法翻页问题
近期在用datagrid-scrollview时,发现如果列数较少,不产生横向滚动条时,则不会触发虚拟滚动翻页的动作,只能查出第一批次的数据信息,经过大量的时间测试改善,发现需要改变源码中的判断条件。仅供参考
基于ASP.NET+C#实现的Gridview, DataGrid, DataList and Repeater 通用翻页控件源码例子
基于ASP.NET+C#实现的Gridview, DataGrid, DataList and Repeater 通用翻页控件源码例子。
DataGrid绑定数据分页出错
DataGrid绑定数据分页出错DataGrid绑定数据分页出错
自定义DataGrid分页块完美实现
自定义DataGrid分页块完美实现
DataGrid使用最佳实践(Best Practices for BataGrid)
DataGrid 中一些常见的用法 包括模板列的使用,导出Excel,分页,自定义控件等等 里面附加有调试用的数据库


