代码之家  ›  专栏  ›  技术社区  ›  Zooking

telerik radgrid不记得页码

  •  0
  • Zooking  · 技术社区  · 15 年前

    我的页面上有一个telerik radgrid控件,用于显示文章列表。如果我单击一个页面,然后单击一篇文章,然后再次返回列表,我将回到第一个页面,而不是以前的页面。

    有解决办法吗?

    2 回复  |  直到 12 年前
        1
  •  4
  •   Solburn    15 年前

    我假设你在做回发,事情都是服务器端的…

    这是一个两步的过程…

    首先,在单击文章的onclick事件中,将页面索引放入会话变量。

    其次,在radgrid的prerender事件中,从先前设置的会话变量中获取页面索引。

    // Set the page index, call this on your OnClick event
    private void SetRadGridPageIndex(int PageIndex)
    {
        Session["RadGridCurrentPageIndex"] = PageIndex;
    }
    
    // Get the page index, call this on RadGrid's PreRender event
    // Don't forget to Rebind the RadGrid
    private void GetRadGridPageIndex()
    {
        // Go to the previously selected page
        if (Session["RadGridCurrentPageIndex"] != null)
        {
            this.RadGrid1.CurrentPageIndex = Convert.ToInt32(Session["RadGridCurrentPageIndex"]);
            this.RadGrid1.MasterTableView.Rebind();
        }
    }
    
        2
  •  0
  •   Dick Lampard    15 年前

    使用网格返回到页面时,是否使用浏览器的“后退”按钮?如果是这样,您将需要为网格页索引(currentpageindex)使用缓存或会话存储(例如),然后将其恢复。

    还要确保将绑定用于NeedDataSource事件或数据源控件。

    迪克