使用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;
}

}

你可能感兴趣的:(使用aspnetpager,返回初始页绑定原页码的方案)