Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Members,

I am using asp.net application C#. In an application i have use "DATATABLE" for binding grid. I have avoid "VIEWSTATE" for stored "DATATABLE" for handling pagination. For that purpose i create a "Public Class", into that class i define "public static DataTable dt_GetMenus = new DataTable()" and use in entire application properly.

I have create services for database manipulation which is act as database layer in our application.

I have create two different databases "SAMPLE1" AND "SAMPLE2" with different data and hosted site in IIS. I have two uses "USER1" for "SAMPLE1" and "USER2" for "SAMPLE2".

Issue :
while "USER1" login to application with "SAMPLE1" database and "USER2" with "SAMPLE2" (send database name dynamically by using login page.) then after refresh or paging first user automatically find details of USER2 for same page.

Exa: 

We have grid view
For USER1 details

ON FISRT PAGE
 Country Name | Status           | Default Country 
 -------------------------------------------------
 India        |   Activated      |   Yes  
 US           |   Activated      |   No 
 ABC1         |   Activated      |   No 
 ABC2         |   Activated      |   No
 ABC3         |   Activated      |   No

ON SECOND PAGE
 Country Name | Status           | Default Country 
 --------------------------------------------------
 ABC4         |     Activated    |   No 
 ABC5         |     Activated    |   No 
 ABC6         |     Activated    |   No 
 ABC7         |     Activated    |   No
 ABC8         |     Activated    |   No

For USER2 details

 N FISRT PAGE
 Country Name | Status           | Default Country 
 -------------------------------------------------
 XYZ1         |   Activated      |   Yes  
 XYZ2         |   Activated      |   No 
 XYZ3         |   Activated      |   No 
 XYZ4         |   Activated      |   No


After refresh or paging USER1 automatically see details of user 2 on his page if both using browsing same page for different database vice versa.

Session id for the both user are different because session variable does not changes i have checked for the session.

I am not able to find out solution for the same. Please guide me or provide any solution for the same.

Thanks

Chetan Chopkar
Posted
Updated 21-Feb-15 19:58pm
v4

1 solution

Hi,

public static DataTable dt_GetMenus = new DataTable() , is this what you are using to pull the data for the grid view and store it so that you can handle the paging etc,?

If so, then there is the issue, because of the static variable. When first USER1 logs in you are selecting records "SAMPLE1 and storing them in static variable.
When USER2 logs in you are again querying SAMPLE2 and storing the data in same static instance of data table. If both users are browsing the same page then the page will show the data of the user who logged in second.

I would rather suggest use some other techniques to achieve the same result instead of static instance.

Hope that helps,
 
Share this answer
 
Comments
Chetan Chopkar 22-Feb-15 1:58am    
Hi TheKarateKid,

Thanks for your suggestion, i know that it happens due using static instance. But i am not able get rid out of problem. Now i am thinking instead of common class, use same page with static datatable. If do you have any other suggestion then please let me know

Thanks
Chetan Chopkar
TheKarateKid 22-Feb-15 17:20pm    
1. You can maintain the Server Side Cache and filter based on the session of the logged in user. This is the one way to do it if the data is small. I would not recommend this if the data/no. of records are more.

2. If you are looking for only paging and that's the only issue, then you can look into server side paging, this will return the records you wish to display per page in the gridview/list view. you can have a stored procedure with page number as a parameter to retrieve the data associated with that page

If you can tell me the number of records we are talking about and also the growth of the data, scalability etc. then it would be more clear to me and I can provide more options

Thanks !
Chetan Chopkar 23-Feb-15 9:46am    
Hi,
Thanks for your reply.

We are dealing with large amount data. On code walk through we observed that the issue occurs only after page post back. Can we implement singleton pattern ? let me know your thoughts.
TheKarateKid 23-Feb-15 13:35pm    
can you post the code snippet to show the way you are retrieving the data based on the logged in user?

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