This question is locked. New answers and comments are not allowed.
Hi
I have a class that encapsulates some filter data and an object to store GridState.
I have the Index() and _Index() methods for grid's data binding.
When the user sorts a grid column, the _Index() action is called and I persist the grid state in Session as follows:
Now when the user leaves the grid page, the most recent grid state is in Session. I would like to know how I can apply the saved grid state in the Index() method when the user comes back to it. I tried the following but it did not work:
I have a class that encapsulates some filter data and an object to store GridState.
public class UserGridFilterModel { public string Title { get; set; } public object GridState { get; set; } }I have the Index() and _Index() methods for grid's data binding.
When the user sorts a grid column, the _Index() action is called and I persist the grid state in Session as follows:
[GridAction]public ViewResult _Index() { UserGridFilterModel filterModel = new UserGridFilterModel(); filterModel.GridState = this.GridRouteValues(); Session["UserGridFilter"] = filterModel;Now when the user leaves the grid page, the most recent grid state is in Session. I would like to know how I can apply the saved grid state in the Index() method when the user comes back to it. I tried the following but it did not work:
public ViewResult Index() { UserGridFilterModel filterModel = new UserGridFilterModel(); if (Session["UserGridFilter"] != null) { filterModel = (UserGridFilterModel)Session["UserGridFilter"]; } if (filterModel.GridState != null) { ViewBag.GridState = filterModel.GridState; }