r p

r p

  • NA
  • 343
  • 0

GridView: Want to keep the selected Items in page index change in Gridview

May 20 2009 5:21 AM
I am displaying a list of products in my Gridview.
I have set the page size and in the page index changing event I am giving the following code:-      
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{       
        List<Products> items = Products.GetProducts();
        GridView1.DataSource = items;
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
}

Now the problem is - in the gridview I have got checkboxes where users can select the products which they like.
They select the items which they like in the first page of the gridview and they go the second page,
but after selecting the items in the second page when the user comes back to the first page of the gridview,
the checkboxes will be unticked
. I mean they will see blank check boxes.
I want to keep the selected items in the checkbox when the user comes back after visiting the
second page, third page and so on. How can I do it?

Answers (1)