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