簡體   English   中英

如何在網格視圖中選擇指定的頁面索引

[英]How to select specified page index in grid view

我有一個網格視圖,在行命令事件中,我正在另一個頁面上重定向,查詢字符串包含網格視圖的當前頁面索引。

在重定向頁面上,我有一個后退按鈕,當我單擊此按鈕時,我要重定向具有指定頁面索引的上一頁

例如:

假設我在我的頁面1上,並且網格視圖的當前頁面索引為15,並且在行命令事件中我正在頁面2上重定向。單擊“返回按鈕”時,它必須重定向到頁面索引為15的頁面1網格視圖。

我的代碼如下:

包含網格視圖的頁面代碼(Page-1)

if (e.CommandName.ToLower() == "application")
{
  Response.Redirect("view-msme-em-1-with-print.aspx?pageIndex=" + i , false);
}

包含Button(Page-2)的頁面的代碼

protected void iBtnBack_Click(object sender, ImageClickEventArgs e)
{      
  Response.Redirect("searchMSMEApplication.aspx?pageIndex=" + Request.QueryString["pageIndex"].ToString() );       
}

頁面加載事件中包含gird視圖的代碼(第1頁)

protected void Page_Load(object sender, EventArgs e)
{
  fillGridOnLoad(); // it fills a grid view  with data
  grvEm2Application.PageIndex = Convert.ToInt32(Request.QueryString["pageIndex"].ToString());

}

當我在“第2頁”上單擊“返回”時,它將重定向到第1頁,但頁面索引不是我設置的。 缺少什么嗎?

試試下面的代碼

protected void Page_Load(object sender, EventArgs e)
{
   grvEm2Application.PageIndex = Convert.ToInt32(Request.QueryString["pageIndex"].ToString());  
   fillGridOnLoad(); // it fills a grid view  with data
}

只需在數據綁定之前設置PageIndex

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM