AspNetPager如何返回到当前页
用的是吴旗娃的分页控件AspNetPager6.0,按照正常方法绑定到GridView控件上,绑定的大致代码如下:
private void DataBind()
{
DataSet dsList = new DataSet();
rInt = GetPageRecord();
dsList = GetGridViewList(AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
GridView.DataSource = dsList.Tables[0].DefaultView;
GridView.DataBind();
AspNetPager.RecordCount = rInt;
AspNetPager.CustomInfoHTML = "记录总数:<font color=\"blue\"><b>" + AspNetPager.RecordCount.ToString() + "</b></font>";
AspNetPager.CustomInfoHTML += " 总页数:<font color=\"blue\"><b>" + AspNetPager.PageCount.ToString() + "</b></font>";
AspNetPager.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager.CurrentPageIndex.ToString() + "</b></font>";
}
private int GetPageRecord()
{
int iRecord = 0;
SqlCommand cmd = new SqlCommand("select count(*) from tb", Conn);
Conn.Open();
iRecord = (int)cmd.ExecuteScalar();
cmd.Dispose();
Conn.Close();
return iRecord ;
}
private DataSet GetGridViewList(int iCurrent, int iPageSize)
{
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("select * from tb", Conn);
Conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds, iCurrent, iPageSize, "list");
cmd.Dispose();
Conn.Close();
return ds;
}
private void AspNetPager_PageChanged(object sender, EventArgs e)
{
DataBind();
}
private void AspNetPager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
GridView.PageIndex = e.NewPageIndex - 1;
AspNetPager.CurrentPageIndex = e.NewPageIndex;
DataBind();
}
绑定的GridView有一列为编辑项,点击该列某项编辑后需要返回到当前页而不是默认的第1页,比如当前页为第3页,那么需要编辑后返回到该页,如果不加控制的话默认是返回到第1页,请高人指点该如何实现
------最佳解决方案--------------------herf=
------其他解决方案--------------------AspNetPager.CurrentPageIndex
or
url
------其他解决方案--------------------把当前的页数传到编辑页,然后从编辑页返回的时候再把页数传回来。
------其他解决方案--------------------楼上说的应该是正确
------其他解决方案--------------------