I having the page in that i have the gridview and page index changing also for every record i have
a check box.on top of the page i have the imagebutton in that when i click that button i am redirecting it into another page
in that page i have a back button which redirects to present page with checkbox and gridview.
what should i do to retain to get the checkbox when ever i check or some thing else?
This is gridview paging:
protected void ManageCalenderShift_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
StoreOldValue();
EmployeeDetails.PageIndex = e.NewPageIndex;
SortedBindDataToGrid();
PupulateoldCheckValue();
}
private void StoreOldValue()
{
ArrayList categoryIDList = new ArrayList();
foreach (GridViewRow row in EmployeeDetails.Rows)
{
Label can_id = (Label)row.FindControl("UserACENumber");
bool result = ((CheckBox)row.FindControl("Chkgrid")).Checked;
if (Session["CHECKED_ITEMS"] != null)
categoryIDList = (ArrayList)Session["CHECKED_ITEMS"];
if (result)
{
if (!categoryIDList.Contains(can_id.Text))
categoryIDList.Add(can_id.Text);
}
else
categoryIDList.Remove(can_id.Text);
}
if (categoryIDList != null && categoryIDList.Count > 0)
Session["CHECKED_ITEMS"] = categoryIDList;
}
private void PupulateoldCheckValue()
{
ArrayList categoryIDList = (ArrayList)Session["CHECKED_ITEMS"];
if (categoryIDList != null && categoryIDList.Count > 0)
{
foreach (GridViewRow row in EmployeeDetails.Rows)
{
Label can_id = (Label)row.FindControl("UserACENumber");
if (categoryIDList.Contains(can_id.Text))
{
CheckBox myCheckBox = (CheckBox)row.FindControl("Chkgrid");
myCheckBox.Checked = true;
}
}
}
}
This is the redirect to another page code that goes to page1:
protected void imgView_Click(object sender, ImageClickEventArgs e)
{
StoreOldValue();
PupulateoldCheckValue();
Response.Redirect("page1.aspx?UserACENumber=" + (Server.UrlDecode(URLSecurity.Encrypt(UserContext.ACENumber))));
}
then in the “page1” i have back button which redirects to “page” aspx :
protected void imgimgBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("page.aspx?UserACENumber=" + (Server.UrlDecode(URLSecurity.Encrypt(UserContext.ACENumber))));
}
now my issue is:
when i check any one checkbox in the “page.aspx” and i go click image button and redirects to “page1.aspx” and come back to current working “page.aspx” whatever the checkbox i have checked gets disappear.
You will have to do that manually.
Maintaining State of CheckBox while Paging in GridView