Generic list stored in session....??




My webpage has a GridView showing rows from a table in the database. All
these rows are stored in the session object -> what's actually stored is
generic list of objects, as this:
List<Message> messages = null;
messages = (List<Message>)HttpContext.Current.Session[sessionKey];

The user should be able to mark one or several rows in the GridView and
select Delete. I wonder how I should implement deleting of the rows. Okay I
need a stored procedure doing the database update. But the rows displayed on
GridView are stored in the session (first check if messages are null, if so
then read from database again).... So if not the session object gets a
update the delete will have no effect.

In other words:
When I delete I must do 2 things: Delete from the database table. AND remove
the deleted item from the session object...

I wonder how this should be done! When using cache it is possible to
configre dependancy, but (from what I understand) cache is shared among all
the users... The GridView shows rows specific for this user. No other user
should be able to see them...

How do I loop through this list "List<Message> messages" and delete objects
having a specific value?
(Lets say I have to loop through the session object and remove the deleted
rows from the List<Message> messages )

Any suggestions??


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

Forum statistics

Latest member

Latest Threads