GridView and paging memory tip

Last post 05-12-2009 1:03 PM by ahazut. 0 replies.

Sort Posts:

  • GridView and paging memory tip

    05-12-2009, 1:03 PM
    • Member
      point Member
    • ahazut
    • Member since 09-03-2008, 3:02 PM
    • Posts 24

    Here I gave a tip about GridView and PagerTemplate:

    http://forums.asp.net/t/1409011.aspx

     

    and this tip is about saving pager index and sorting properties:

        protected void Page_Unload(object sender, EventArgs e)
        {
            // Save grid view properties
            Session["MainGVP"] = string.Format("{0};{1};{2}", grdRecords.SortExpression, grdRecords.SortDirection, grdRecords.PageIndex);
        }

     

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Load grid view here


                // Set grid view properties
                if (Session["MainGVP"] != null)
                {
                    string[] Items = Session["MainGVP"].ToString().Split(';');
                    grdRecords.Sort(Items[0], (SortDirection)Enum.Parse(typeof(SortDirection), Items[1]));
                    grdRecords.PageIndex = int.Parse(Items[2]);
                }
            }       
        }

     

     enjoy...

Page 1 of 1 (1 items)