Maintaining GridView current page index after navigating away from Gridview page

前端 未结 4 1682
-上瘾入骨i
-上瘾入骨i 2020-12-18 13:27

I have a GridView on ASP.NET web form which I have bound to a data source and set it to have 10 records per page.

I also have a hyper link column on the GridView,

4条回答
  •  时光说笑
    2020-12-18 13:46

    you must use query string and is recommended, otherwise you can use session object but don't use that for this as you may have grid view opening in different pages so use query string .

    gridView1.CurrentPageIndex = (Request["pageNo"] != null) ? Request["pageNo"] as int : 0; 
    gridView1.DataSource = myDataSet;
    gridView1.DataBind();
    

    you can update your link on GridView_DataBound event

提交回复
热议问题