Wanna maintain table state in different function call
-
Hi folks, I want my datatable to persist through diff function calls, but I can not use static datatable as it not read only. Neither I want to use session coz its an overhead. Is there any other way to do this... I know the forum is full of great techies, someone might be kind enough to help.
-
Hi folks, I want my datatable to persist through diff function calls, but I can not use static datatable as it not read only. Neither I want to use session coz its an overhead. Is there any other way to do this... I know the forum is full of great techies, someone might be kind enough to help.
Hi joindotnet, what do you want to achieve exactly? You could store the datatable into a static dictionary, using guids as keys. This guid could be attached to a hidden field, that the web form always transport. I know this is how sessions work, but this is more a lightweight implementation.
static Dictionary<guid,> dictTables = new Dictionary<guid,>(); public void MyFunction() { // get GUID from Hiddenfield Guid oGuid = new Guid(this.MyHiddenField.Value); DataTable oCurTable = dictTables[oGuid]; }
Regards SebastianIt's not a bug, it's a feature! Me in Softwareland.
-
Hi joindotnet, what do you want to achieve exactly? You could store the datatable into a static dictionary, using guids as keys. This guid could be attached to a hidden field, that the web form always transport. I know this is how sessions work, but this is more a lightweight implementation.
static Dictionary<guid,> dictTables = new Dictionary<guid,>(); public void MyFunction() { // get GUID from Hiddenfield Guid oGuid = new Guid(this.MyHiddenField.Value); DataTable oCurTable = dictTables[oGuid]; }
Regards SebastianIt's not a bug, it's a feature! Me in Softwareland.
Hi Sebastian, Thanks for ur help.Could u plz tell if I implement this solution my table would not be shared and each user would have her own copy. Can I have a more detailed description or a link where I can understand the working of dictionary. I would be so nice of u... Thanks again
-
Hi Sebastian, Thanks for ur help.Could u plz tell if I implement this solution my table would not be shared and each user would have her own copy. Can I have a more detailed description or a link where I can understand the working of dictionary. I would be so nice of u... Thanks again
Hi, for a description of a dictionary have a look here http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^]. The table itself will not be shared, but the dictionary. You have to be careful by using this because you have to manage (cleanup etc.) all by yourself. Also the static dictionary will only live as long as the IIS-process is running (which will be recycled every 24 hours, am I right?). But why don't you want to use sessions? (The solution I proposed is a kind of self-implemented session).
It's not a bug, it's a feature! Me in Softwareland.
-
Hi folks, I want my datatable to persist through diff function calls, but I can not use static datatable as it not read only. Neither I want to use session coz its an overhead. Is there any other way to do this... I know the forum is full of great techies, someone might be kind enough to help.
Using the session is the best way to create a per user object. A static variable will be the same for all users.
Christian Graus Driven to the arms of OSX by Vista.
-
Hi, for a description of a dictionary have a look here http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^]. The table itself will not be shared, but the dictionary. You have to be careful by using this because you have to manage (cleanup etc.) all by yourself. Also the static dictionary will only live as long as the IIS-process is running (which will be recycled every 24 hours, am I right?). But why don't you want to use sessions? (The solution I proposed is a kind of self-implemented session).
It's not a bug, it's a feature! Me in Softwareland.
Thanks alot for the link.I ll try this. I am already using session for the solution but it's making my site very slow as my datatable is very large. When a user will use it on a dial up connection it would suck him up. Dossn't session slows the site down?? I mean I don't know I have read it at many places.
-
Using the session is the best way to create a per user object. A static variable will be the same for all users.
Christian Graus Driven to the arms of OSX by Vista.
Hi Christian, yep you're right, but as I understood the question he wants the datatable to be not the same for all users. Thought using a static dictionary storing the datatables would be a better way... By the way: Don't know nothing about that the session is slowing down the site. Did you heard something like this before? Kind regards Sebastian
It's not a bug, it's a feature! Me in Softwareland.
-
Thanks alot for the link.I ll try this. I am already using session for the solution but it's making my site very slow as my datatable is very large. When a user will use it on a dial up connection it would suck him up. Dossn't session slows the site down?? I mean I don't know I have read it at many places.
If it is to be for many users (i.e. the same), have you looked at using the .net Cache?
-
Hi Christian, yep you're right, but as I understood the question he wants the datatable to be not the same for all users. Thought using a static dictionary storing the datatables would be a better way... By the way: Don't know nothing about that the session is slowing down the site. Did you heard something like this before? Kind regards Sebastian
It's not a bug, it's a feature! Me in Softwareland.
SeMartens wrote:
Don't know nothing about that the session is slowing down the site
Session store data on server side, so it can causes performance overhead. But Its depends on your data size of session. You can Enable Trace of your page and Check the Session Data Object Size. Good luck !!!
cheers, Abhijit My Recent Article : Beginner's Guide to ASP.NET Application Folder
-
Hi folks, I want my datatable to persist through diff function calls, but I can not use static datatable as it not read only. Neither I want to use session coz its an overhead. Is there any other way to do this... I know the forum is full of great techies, someone might be kind enough to help.