Keeping track of checkmarks.

M

Mike Adkins

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!

Thanks!
Mike
 
S

smasaitis

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
viewstate.

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.
 
M

mike adkins

smasaitis,

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.

Thanks,
Mike
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top