Login
Latest Development Blogs
Forum Topics Post
Browse By Tag
I have a scenario where a grid has multiple pages....the user clicks page 5 ]on the grid. I want to be able to save that they are on page 5 of the grid when the leave the page. I also want to set the grid back to that page when they come back the grid.
How do I get the current page of the grid in the code behind? Also, how do I set the grid back to that page in the code behind?
Hello,
Normally, you could not get it from server side because there is no method or property for this scenario. It only can be done via javascritp. However, you can pass the data from client(javascript) to server.
E.g
function WebGrid1_OnAfterResponseProcess(controlId, actionName, lastRequestObject, xmlResponseObject) { if (actionName != "Custom") { var WebGrid1 = ISGetObject(controlId); var pageIndex = WebGrid1.CurrentPageIndex; WebGrid1.AddInput("pageIndex", pageIndex.toString()); WebGrid1.SendCustomRequest(); } return true; }
protected void WebGrid1_InitializePostBack(object sender, ISNet.WebUI.WebGrid.PostbackEventArgs e) { if (e.Action == ISNet.WebUI.WebGrid.PostBackAction.Custom) { pageIndex = Request["pageIndex"] as string; } }
Regards,Handy
How do I set the grid to load that specific page in the code behind instead of loading the first page?
This cannot be done in server side. You only can do it in client side with OnAfterInitialize event and run below code.
var grid=ISGetObject("WebGrid1"); grid.GotoPage(2);