首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

AspNetPager怎么返回到当前页

2012-12-16 
AspNetPager如何返回到当前页用的是吴旗娃的分页控件AspNetPager6.0,按照正常方法绑定到GridView控件上,绑

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 
[其他解释]
把当前的页数传到编辑页,然后从编辑页返回的时候再把页数传回来。

[其他解释]
楼上说的应该是正确

------其他解决方案--------------------


回帖是一种美德!每天回帖即可获得 10 分可用分
[其他解释]
链接过去就行了吧。
[其他解释]
给Gridbind()里设一个参数哦,参数为当前页码!然后返回时给参数为你当前表所显示的页码数就可以了
[其他解释]
顶一个,,遇到同样的问题...楼主解决了吗,,
[其他解释]
是不是指把当前页的CurrentPageIndex值传到编辑页面,然后返回时使用该值?
[其他解释]
ding!
[其他解释]
遇到同样问题了 顶一个
[其他解释]
遇到一样的情况,哪位大侠可帮忙!!!
[其他解释]
我想要一个demo 那位大侠愿意奉献?

热点排行