使用aspnetpager,返回初始页绑定原页码的方案

最近在使用分页控件aspNetPager.dll,要实现分页后,点击链接到其它页,返回仍保存原页码的功能。

可以通过session来实现,不过要把spNetPager1.CurrentPageIndex, AspNetPager1.RecordCount全放在session中.

当执行AspNetPager1.CurrentPageIndex =currentPageNum,会自动的重新绑定一次。此时需判断一下,初始页currentPageNum 是否有值,没有值则调用session值,再执行AspNetPager1.CurrentPageIndex 时,此时inv.currentPageNum又初始化了,不过AspNetPager1.CurrentPageIndex,AspNetPager1.RecordCount 已有值。再放session中,以下次使用。

部分代码如下:

page_load中

if (Request.QueryString["detail"] != null)
{
         inInvSession = (AdjustStorageInfo)Session["searchParamInv"];
        

protected void AspNetPager1_PageChanged1(object sender, EventArgs e)
{
         bindData(searchContent());
 }

private void bindData(AdjustStorageInfo inInv)
{
        if (inInv.currentPageNum == 0)
        {
                inInv.currentPageNum = AspNetPager1.CurrentPageIndex;
                inInv.recordCount = AspNetPager1.RecordCount;
         }

}

        

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值