Keeping track of checkmarks.

Discussion in 'ASP .Net Datagrid Control' started by Mike Adkins, Dec 19, 2003.

  1. Mike Adkins

    Mike Adkins Guest

    Hello all,

    I have a pretty cool situation here that I thought I had figured out.

    I have a datagrid that is 4 columns bound to a table and another column that
    is a checkbox. My goal was to keep track of the items that I have checked
    while I am changing pages. So every time I change pages I would loop though
    the grid on the current page and find out if a row has been check or not.
    If it had been checked previously and then unchecked, I remove that item
    from the array that I created in a separate module. If the item needs to be
    added to the array, I do so. Then the page changes. So, when I go back to
    a page that has checkboxes that need to be checked, then they are checked.

    The problem I am running into is when multiple users are on the system using
    the same form at the same time. That is really big problem. I see what
    they have checked and they can see what I have checked. The reason being
    the way the array is defined. I have defined the array as public in a
    separate module outside of the main form class. I have tried to move the
    declaration of the array into the form but then I cannot keep the data in
    the array when I do a postback or change pages. Any thoughts or
    suggestions... I am so close, I don't want to scrap this cool work. :)

    Sorry it is so long!

    Mike Adkins, Dec 19, 2003
    1. Advertisements

  2. smasaitis

    smasaitis Guest

    I have done something very similar to what you are doing.

    But what I did was delcare the array as private and store it in the

    for C#:
    ViewState["myArray"] = myArray

    Then to access the array from ViewState:

    myArray = (Array)ViewState["myArray"]

    Each page has its own viewstate which exists for the life of the page
    and is exclusive to the current user viewing the page.

    Let me know if this helps.
    smasaitis, Dec 19, 2003
    1. Advertisements

  3. mike adkins

    mike adkins Guest


    That worked out great. I actually got it working by storing the array
    in a session variable. I didn't like doing it that way, so thank you.
    I have never worked with viewstate before. I will be using is more
    often in the future.


    *** Sent via Developersdex ***
    Don't just participate in USENET...get rewarded for it!
    mike adkins, Dec 19, 2003
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
  2. Utter Newbie
    Utter Newbie
    Jul 28, 2003
  3. Manuel
    John Saunders
    Dec 11, 2004
  4. =?Utf-8?B?dHBlcnJp?=
    Jul 12, 2005
  5. xzzy

    keeping track of threads

    xzzy, Oct 6, 2005, in forum: ASP .Net

Share This Page