datagrid无法翻页

soveran soveran 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位高手帮忙看看,代码如下:
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();
}
...全文
评论 4
收藏 已收藏
分享
返回顶部
soveran
.NET社区 62,272 成员 668,968 内容