问题描述
我的页面上有一个telerik radgrid控件,用于显示文章列表.如果单击页面,然后单击文章,然后再次返回列表,那么我将返回首页,而不是之前的页面.
I have a telerik radgrid-control on my page for showing a list of articles. If I click a page, then an article and then back to the list again I am back at the first page instead of the one I was at before.
有解决方案吗?
推荐答案
我假设您正在执行回发,并且事情在服务器端...
I'm assuming you're doing a postback and things are server side...
这是一个两步过程...
This is a 2 step process...
首先,在单击文章的OnClick事件中,将页面索引放入会话变量中.
First in the OnClick event for clicking on an article, put the page index into a session variable.
第二,在RadGrid的PreRender事件中,从先前设置的会话变量中获取页面索引.
Second, in the RadGrid's PreRender event get the page index from that previously set session variable.
// 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();
}
}
这篇关于Telerik radgrid不记得页码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!