【发布时间】:2013-05-16 08:29:29
【问题描述】:
我有一个网格视图,在行命令事件上,我使用包含网格视图当前页面索引的查询字符串重定向到另一个页面。
在重定向页面上,我有一个后退按钮,当我单击此按钮时,我希望使用指定的页面索引重定向上一页
例如:
假设我在第 1 页,网格视图的当前页面索引为 15,并且在行命令事件上,我正在第 2 页重定向。当单击“后退按钮”时,它必须重定向到第 1 页,并带有页面索引15 个网格视图。
我的代码如下:
包含网格视图的页面代码(第 1 页)
if (e.CommandName.ToLower() == "application")
{
Response.Redirect("view-msme-em-1-with-print.aspx?pageIndex=" + i , false);
}
包含按钮的页面代码(Page-2)
protected void iBtnBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("searchMSMEApplication.aspx?pageIndex=" + Request.QueryString["pageIndex"].ToString() );
}
包含网格视图(page-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());
}
当我单击“page-2”上的“Back”时,它会重定向到 page-1,但页面索引与我设置的不同。有什么遗漏吗?
【问题讨论】:
-
尝试在 PreRender 或网格数据绑定事件中设置它。
-
尝试设置
PageIndex之前在gridview上调用Databind()