Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. grid view page index

grid view page index

Scheduled Pinned Locked Moved ASP.NET
cssdatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrcooll
    wrote on last edited by
    #1

    hi all, how can i maintain gridview page index while navigation from the form and getting back by browser back button. i tried to use this approach:

    public int PageIndex
    {

        get
        {
            if (Session\["DGApplicationPageIndex"\] != null)
            {
                return (int)Session\["DGApplicationPageIndex"\];
            }
            else
            {
                return 0;
            }
        }
        set
        {
            if (value != -1)
            {
                Session\["DGApplicationPageIndex"\] = value;
            }
            else
            {
                Session\["DGApplicationPageIndex"\] = null;
            }
    
        }
    
    }
    

    protected void DGApplication_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
    DoSearch(TextBox1.Text);
    DGApplication.PageIndex = e.NewPageIndex;
    PageIndex = DGApplication.PageIndex;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    DoSearch("-1");
    }
    DGApplication.PageIndex = PageIndex;
    PageIndex = -1;

    }
    
    N 1 Reply Last reply
    0
    • M mrcooll

      hi all, how can i maintain gridview page index while navigation from the form and getting back by browser back button. i tried to use this approach:

      public int PageIndex
      {

          get
          {
              if (Session\["DGApplicationPageIndex"\] != null)
              {
                  return (int)Session\["DGApplicationPageIndex"\];
              }
              else
              {
                  return 0;
              }
          }
          set
          {
              if (value != -1)
              {
                  Session\["DGApplicationPageIndex"\] = value;
              }
              else
              {
                  Session\["DGApplicationPageIndex"\] = null;
              }
      
          }
      
      }
      

      protected void DGApplication_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
      DoSearch(TextBox1.Text);
      DGApplication.PageIndex = e.NewPageIndex;
      PageIndex = DGApplication.PageIndex;
      }

      protected void Page_Load(object sender, EventArgs e)
      {
      if (!Page.IsPostBack)
      {
      DoSearch("-1");
      }
      DGApplication.PageIndex = PageIndex;
      PageIndex = -1;

      }
      
      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      And what happens with this? Why reset the page index?? PageIndex = -1;


      only two letters away from being an asset

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups