Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I am new to ASP.Net.
I have created a Web Application which has multiple users.
Users save data at run time which is maintained in sessions, but the data of different users get combined and displays to all users.

For example: Users enters data in text boxes and on add button click it goes to grid. The data of all users get combined in grid as all users start adding.

I also do not know how to use global.asax.

I tried to serach for help, but can't find anything specific.

Please any one can help me to maintain session by session ID.
Posted
Updated 5-Jan-11 21:43pm
v2
Comments
Dalek Dave 6-Jan-11 3:43am    
Edited for Syntax and Readability.

Take a look at this

Exploring Session in ASP.Net[^]
 
Share this answer
 
Comments
Dalek Dave 6-Jan-11 3:44am    
Good Link.
I think you need to have a clear understanding of handling Sessions in Asp.net, before starting implementation. This[^] may be a good resource for you to start with.

However, let me try to help you a bit

As you said, users will save data and the data will be saved into the Session. But, as each user have their own session, a particular user's data will not be available to another user's data.

So, either you have to save the data in the Database, or, if you don't do that for some reason, you have to save user's data in Application state or Cache.

Application or Cache is not user specific, rather, they are global to all users. So, if all users save their data to either Application, or, Cache, the combined data will be the same for all users.

You can see http://www.asp.net/general/videos/lesson-4-understanding-web-application-state[^] to learn about Application state.

Best of luck.
 
Share this answer
 
Comments
Dalek Dave 6-Jan-11 3:44am    
Good Answer.
Ashwani Dhiman 6-Jan-11 4:12am    
Thanks for your Reply.

I just want to explore little bit..


I am saving a Data table to Session using :
Session["DataTable "] = dt;
I use this Session throughout the web page to maintain data.

When I lo-gin through different users. Users fill data and data goes to data-table and display in grid on web-Page. As all users start filling data, data should maintain differently for all users. But it start getting combined may be due to saving in same "session["DataTable "] = dt".
I just want to avoid the data to get combined and maintain that Session["DataTable"]
different for all users.
Sandesh M Patil 6-Jan-11 5:17am    
Add Global.asax. Use session.sessionid to differentiate between different users.
Hi Dave,
Let me know one thing- are you binding your grid from database or from Session data? As per my understanding about your question, you are saving data in Session as well as in database and that's why data after clicking Add button get combined for all users and visible to all users in the grid. Any way I've two solutions regarding your problem:

First Solution:-

1. Add your run time data in a collection object e.g. List or Array.
2. Bind your grid from this collection object.
3. Store this collection object in the Session using a key.
4. Follow steps 1-3 for each addition.

Second Solution:-

1. Add UserID column in your database table to identify data as per user.
2. Now you can fetch data from this table for a given user.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900