Click to See Complete Forum and Search --> : Static DataSet


praveenvvn
August 17th, 2004, 09:56 AM
Hi, This is regarding an ASP.NET (C#) Web Application. I've written a common base class which does some common operations. And then there are several pages that inherits the funtionalities from this common base class.

In the base class, I've declared a static dataset. This dataset serves as an input to the datagrid in all the individual aspx pages. Each of these individual aspx pages has sorting, paging & searching functionalities. Because of the static nature of the dataset, even during a post back, the values in the dataset is retained, helping me in managing my sorting, paging & searching functionalities.

But when it comes to multiuser scenario (2 instances of browsers calling the same functionality of an aspx page), the static dataset is creating an issue. For e.g., I open 2 instances and look at a common page, say one.aspx. In browser 1, I search in the datagrid in one.aspx based on a particular criteria. In there I populate the static dataset with the records retrieved. In browser 2, I try to search the datagrid in the one.aspx for a different criteria. But my static dataset has the values of that of browser 1 ,and hence returns me inappropriate results.

The problem is, I can't do away without static, because there are many one.aspx's which is using the base class. Is there anyway in which I can retain a seperate instance of the static dataset for each of the one.aspx's or any method through which I can solve this multiuser issue.

Hope I was clear in my issue. Thanks for replies.

MRutledge
August 20th, 2004, 10:29 AM
The answer to your question is, "Yes you can do without the static dataset" This is what we have viewstate for. You need to either set flags in the viewstate or store your dataset in the viewstate. My recommendation is to use flags in the view state and create a sorting class that stores that flag. If you need more information do a google search on ViewState or look on msdn, there are a ton of great articles out there explaining how to do this.