【问题标题】:ASP.NET Gridview paging not retaining when we come back from another page using browser back button当我们使用浏览器后退按钮从另一个页面返回时,ASP.NET Gridview 分页不保留
【发布时间】:2013-05-13 10:39:07
【问题描述】:

我的 ASP.NET 应用程序上有一个 gridview,我设置了 AutoGenerateColumns = false 并以编程方式填充它。此网格视图在更新面板中排序和分页工作正常。我对此没有任何意见。我有另一个页面,通过单击此网格视图的特定列进行导航,它显示了诸如主详细信息之类的记录的更多信息。当按下浏览器后退按钮时,它会转到第一页。我希望它记住我从哪个页面开始。

最近 3 天我一直在寻找。我已经实现了 AddHistoryPoint,但它不起作用。

 protected void detailsGrid_PageIndexChanged(object sender, EventArgs e)
{
    if (ScriptManager1.IsInAsyncPostBack && !ScriptManager1.IsNavigating)
    {
        ScriptManager1.AddHistoryPoint("page", detailsGrid.PageIndex.ToString());
    }
}
protected void ScriptManager1_Navigate(object sender, HistoryEventArgs e)
{
    string indexPage = e.State["page"];
    if (string.IsNullOrEmpty(indexPage))
    {
        detailsGrid.PageIndex = 0;
    }
    else
    {
        int pageNo = Convert.ToInt16(indexPage);
        detailsGrid.PageIndex = pageNo;
        loadmainGrid();
    }
}

【问题讨论】:

    标签: asp.net ajax gridview paging scriptmanager


    【解决方案1】:

    试试这个:

    int pageNo = Convert.ToInt16(indexPage);
    loadmainGrid();
    detailsGrid.PageIndex = pageNo;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 2017-09-26
      相关资源
      最近更新 更多