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. Gridview page change is affecting sessions

Gridview page change is affecting sessions

Scheduled Pinned Locked Moved ASP.NET
questionhelp
4 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.
  • E Offline
    E Offline
    eyeseetee
    wrote on last edited by
    #1

    Hi I have the following code which is running on the page load: ArrayList originalTrue = new ArrayList(); ArrayList originalFalse = new ArrayList(); for (int x = 0; x < GridView4.Rows.Count; x++) { GridViewRow row = GridView4.Rows[x]; bool isCheckedIgnore = ((CheckBox)row.FindControl("chkIgnore")).Checked; string strID = GridView4.DataKeys[x].Values[0].ToString(); if (strID != null) { if (isCheckedIgnore == true) { originalTrue.Add(strID.ToString()); } else { originalFalse.Add(strID.ToString()); } } } ViewState["originalTrue"] = originalTrue; ViewState["originalFalse"] = originalFalse; The problem is when I go to the second page of the gridview it doesnt run.How can I get the code to run on the second page of the gridview? thanks The answers posted by me are suggestions only and cannot be used in anyway against me.

    S 1 Reply Last reply
    0
    • E eyeseetee

      Hi I have the following code which is running on the page load: ArrayList originalTrue = new ArrayList(); ArrayList originalFalse = new ArrayList(); for (int x = 0; x < GridView4.Rows.Count; x++) { GridViewRow row = GridView4.Rows[x]; bool isCheckedIgnore = ((CheckBox)row.FindControl("chkIgnore")).Checked; string strID = GridView4.DataKeys[x].Values[0].ToString(); if (strID != null) { if (isCheckedIgnore == true) { originalTrue.Add(strID.ToString()); } else { originalFalse.Add(strID.ToString()); } } } ViewState["originalTrue"] = originalTrue; ViewState["originalFalse"] = originalFalse; The problem is when I go to the second page of the gridview it doesnt run.How can I get the code to run on the second page of the gridview? thanks The answers posted by me are suggestions only and cannot be used in anyway against me.

      S Offline
      S Offline
      simsen
      wrote on last edited by
      #2

      If you have the code in a if (!IsPostBack) it will only run when the page loads and not each time there is a post back. Is this the case here?

      E 1 Reply Last reply
      0
      • S simsen

        If you have the code in a if (!IsPostBack) it will only run when the page loads and not each time there is a post back. Is this the case here?

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #3

        Well it currently sits in a ispostback = false. The problem is that the viewstate seems to keep the state of the page over the postback which I dont want to do. I need to store the arraylist in some sort of session so that I can check it when the page of the gridview changes. This is because the values it is storing in the viewstate for the row id is then being used when the gridview page changes which obviously is no good. How can I store the arraylist in a session so that it works over multiple pages in the gridview? thanks

        The answers posted by me are suggestions only and cannot be used in anyway against me.

        E 1 Reply Last reply
        0
        • E eyeseetee

          Well it currently sits in a ispostback = false. The problem is that the viewstate seems to keep the state of the page over the postback which I dont want to do. I need to store the arraylist in some sort of session so that I can check it when the page of the gridview changes. This is because the values it is storing in the viewstate for the row id is then being used when the gridview page changes which obviously is no good. How can I store the arraylist in a session so that it works over multiple pages in the gridview? thanks

          The answers posted by me are suggestions only and cannot be used in anyway against me.

          E Offline
          E Offline
          eyeseetee
          wrote on last edited by
          #4

          Fixed

          The answers posted by me are suggestions only and cannot be used in anyway against me.

          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