Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Wanna maintain table state in different function call

Wanna maintain table state in different function call

Scheduled Pinned Locked Moved ASP.NET
help
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    joindotnet
    wrote on last edited by
    #1

    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.

    S C B 3 Replies Last reply
    0
    • J joindotnet

      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.

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      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 Sebastian

      It's not a bug, it's a feature! Me in Softwareland.

      J 1 Reply Last reply
      0
      • S SeMartens

        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 Sebastian

        It's not a bug, it's a feature! Me in Softwareland.

        J Offline
        J Offline
        joindotnet
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • J joindotnet

          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

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #4

          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.

          J 1 Reply Last reply
          0
          • J joindotnet

            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.

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • S SeMartens

              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.

              J Offline
              J Offline
              joindotnet
              wrote on last edited by
              #6

              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.

              P 1 Reply Last reply
              0
              • C Christian Graus

                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.

                S Offline
                S Offline
                SeMartens
                wrote on last edited by
                #7

                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.

                A 1 Reply Last reply
                0
                • J joindotnet

                  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.

                  P Offline
                  P Offline
                  Paddy Boyd
                  wrote on last edited by
                  #8

                  If it is to be for many users (i.e. the same), have you looked at using the .net Cache?

                  1 Reply Last reply
                  0
                  • S SeMartens

                    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.

                    A Offline
                    A Offline
                    Abhijit Jana
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • J joindotnet

                      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.

                      B Offline
                      B Offline
                      Brij
                      wrote on last edited by
                      #10

                      You have one more option to use some application variable and if you have to use on same page(if UI page) then you can use viewstate too.

                      Cheers!! Brij

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups