Gridview: Maintain selected checkbox state while Paging

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ananthu
    New Member
    • Sep 2007
    • 87

    Gridview: Maintain selected checkbox state while Paging

    Hi,

    I have a gridview with paging option. I want to maintain the state of the checkbox column in gridview for each page.

    I used vb.net coding.

    I used the following link for this purpose,

    http://aspalliance.com/774_Maintaining _State_of_Check Boxes_While_Pag ing_in_a_GridVi ew_Control

    It worked properly.

    But when i check all the checkbox of page1 in gridview and click the next page, it shows that all checkbox of page2 is checked.

    I know the reason for it. Because the index of the gridview row for each page will start from zero only. This causes the problem.

    My requirement: I will check 2 checkbox in page1 of gridview and 1 check box in page2. I want to maintain their individual page state checkbox.

    Please help me.
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello Ananthu,

    This can be done. But, first lets have you post what you have done so far and then we can add/edit what you have. This way you get the best fit solution to your question.

    Happy Coding,
    CroCrew~

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You need to keep track of what has been selected.
      You essentially want to keep track of the unique IDs for each row that has been selected. Please remember that you can Sort a GridView and so you can't just keep track of the indexes...you should use some sort of unique identify for each row.

      You will need to store this somewhere.
      You could store the selected unique IDs in Session, ViewState, Cookies....a HiddenField...w hatever you fancy so long as it is accessible between postbacks.

      Every time the user postsback to the server you should update your list of selected unique IDs so that you are always current.

      That's pretty much it.

      -Frinny

      Comment

      Working...