storing in Viewstate Vs rereading XmlDocument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KittyKit
    New Member
    • Dec 2009
    • 4

    storing in Viewstate Vs rereading XmlDocument

    Hi

    I have an aspx page which reads from a Xml file using XmlDcoument object, process it and stores the data in a datatable. The datatable may contain from 10 to max 1000 rows depending on the Xml file.

    I am using couple of update panels and hence there are frequent postbacks expected. My question is which would be better performancewise :

    1. Store the datatable in viewstate OR
    2, Read the data from Xml file and build the datatable during each postback.

    Pls note that the xml file is very big and the processing involves multiple loops before storing the data in the required format in the datatable.

    any help would be appreciated.
    thanks
    Kit.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Caching is a very good idea.
    I don't know if the ViewState is the best idea for this case because you're going to have to pass a lot data between the client and server.

    Look into ASP.NET caching.

    -Frinny

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      Cache it and if cache is null re-read it. Viewstate is not a good option.
      Link

      Comment

      • KittyKit
        New Member
        • Dec 2009
        • 4

        #4
        Many thanks for the replies. Yup, I went through the ASP.NET cache resources briefly. I understand that when there's a memory shortage, the cache data would be flushed. Am i right?
        Well I have two datatables: One is exactly what I explained above. If I choose to use Cache, I would not mind to rebuild it if in rare case, this got flushed.
        My second datatable is bit more critical. I update the rows based on the user selections during partial postbacks and want to retain it until the submit button is pressed. In this case I cannot afford ti loose the data from this datatable incase of memory flush. Do you guys recommend me to use Cache still or any other advices???
        Please note that - this tables are used only in a single page (not across multiple pages) and my application has multiple users and I expect each user to have their own copy of the datatable.
        Thanks.

        Comment

        • PRR
          Recognized Expert Contributor
          • Dec 2007
          • 750

          #5
          Yes Cached data will be removed if memory is "full". For data that is specific to the user, you could use session.
          Link

          Comment

          Working...