I have a Radgrid on ASP.NET Form (RadControls for ASP.NET AJAX Q2 2012 SP2 with VS 2010) , which is bound to a Linq data source and set it to have 10 records per page , sorting, filtering is enabled. Also have a hyper a link column (Radgrid Mastertable Databound column) on the Radgrid, such that a user can click it & navigate to another external page (details.aspx) from the list. I am passing Master Table Primary Key that is Parent key of all rows in Detail Page. On the details page, they have "Back" button to return to the RadGrid page.
I am looking for sample code snippet on the Server/Client Side on how to specify the page/row index to set the RadGrid after data binding. The idea is to ensure the user navigates to the same Radgrid (Parent) page/row index they were originally on after exiting from details.aspx.
14 Answers, 1 is accepted
It did not work. Basically I have 2 pages, Default.aspx and Default2.aspx. Each of the page has 2 Link buttons (LinkButtonDefault and LinkButtonDefault2) on top of Grid to Navigate between pages. Assuming if I am in Page 6 of Default.aspx and clicked Link button LinkButtonDefault to Navigate to Default2.aspx.
My intention is upon Navigate back from Default2.aspx (via its Link Button) to Default.aspx, Page 6 of Default.aspx will be the current page Index. But unfortunately its opening the 1st Page of Default.aspx.
Below is my Declaration of each Page:
In this case, where would I set the CurrentPageIndex? Thanks for any help.
You can use the same approach Jayesh suggested. You can save the current page index in ItemDataBound event like below.
Thanks a lot Princy & Jayesh for helping Sharon with her navigating controls. When I started Rad Controls about 5 yrs ago, Princy & Shinu and later Jayesh helped me a lot. Sincerely appreciate that.
All the best,
I'm trying to go one more step by attempting to make the selected row be what it used to be before the user left the current page. WIth Jayesh and Princy's solution, I get to the previous page fine, now I want the previous row to persist. I tried something on my own using some code provided by Princy for another issue, and I nearly got it to work. Unfortunately, it is causing some undesirble side effect, which I dont know how to fix, although for the experts out there I'm sure it is evident. This issue being when I click on a row, it reverts back to the previous row, and then a second click will work. Thanks.
I set the CurrentRowIndex session variable to the current index.
Thanks for any help.
You can implement the approach demonstrated in the following topic to preserve selection upon databinding operations:
Please note that this approach requires the grid to be ajaxified:
To get the selected items through all pages on a single button click, you can implement the approach demonstrated in this code-library:
I hope this helps.
the Telerik team
In RadGrid, when i click on pageIndex 4 first time . it show CurrentpagesIndex 0.
protected void Page_Load(object sender, EventArgs e)
int CurrentPageIndex = 0;
if (Session["EmployerCurrentPageIndex"] != null)
int.TryParse(Convert.ToString(Session["EmployerCurrentPageIndex"]), out CurrentPageIndex);
EmployerLinkGrid1.CurrentPageIndex = CurrentPageIndex;
string strCurrentPageIndex = EmployerLinkGrid1.MasterTableView.CurrentPageIndex.ToString();
protected void EmployerLinkGrid1_ItemCommand(object sender, GridCommandEventArgs e)
Session["EmployerCurrentPageIndex"] = EmployerLinkGrid1.CurrentPageIndex;
I check it many way, when click on PagesIndex 4 , it should not show 0. everytime it show previous value.
When click on pageIndex 4, it show 0
then click on pageIndex 1, it show 3
Its really confusing.
the Telerik Team
protected void EmployerLinkGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
string str = e.NewPageIndex.ToString();
the Telerik Team
The GridSettingsPersister class is outdated long ago and no longer supported. Now this requirement can be better achieved using RadGrid in combination with RadPersistenceFramework and using the correct time in the page life cycle to load the saved settings:
I am also sending 2 RadGrid web sites to demonstrate practical implementations.