Datagrid with unbound column(checkbox)

M

Mike

Hello all,

I think I have a scope problem here, and I don't know how
to fix it.

I have a module that contains the declaration for an
arraylist. Then I have a form that uses the arraylist,
populates and deletes items in it. The arraylist is fine
unless there are multiple people in the form doing
transactions that affect the arraylist. User 1 adds 5
records to the arraylist as well does user 2. When the
page does a postback, user 1 and 2 both see 10 records in
the arraylist. I have tried to define the arraylist in
the form but everytime the page does a postback, the
array is recreated and I lose my data. Any ideas on how
to fix this problem.

Thanks,
Mike
 
S

Sink

Hi Mike,
Sounds like you have a static defined
ArrayList in your module.
You could set up seperate lists for each User of the
form.
If you are using Sessions to track such data and
reside in a class type module, then you will need to
access the HttpContext to get access to the individual
Session data.

....
Using System. Collections;
Using System.Web;
....

public ArrayList my_list;

HttpContext ctx = HttpContext.Current;

my_list = (ArrayList)ctx.Session["my_list"];
if(my_list == null){
my_list = new ArrayList();

}

// To Save your list

ctx.Session["my_list"] = my_list;

Alternatively, of course, you could just expand
your ArrayList to contain some class of objects that
include the UserID or some sort of Identifier and
then search the list for only those.

Finally, if you move into your code behind module,
you can use Session without the HttpContext addressing.

Regards
G.,
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top