How to save GridView Column values and retrieve them without using a database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jawaddhair
    New Member
    • Apr 2010
    • 1

    How to save GridView Column values and retrieve them without using a database.

    Hi All,

    I would like to save Gridview with all of the columns value and reload the same grid without using database??
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You would cache the DataSource that you use for the GridView and reuse that cached value instead of going to the database again.


    -Frinny

    Comment

    • robjens
      New Member
      • Apr 2010
      • 37

      #3
      I don't have much experience with the GridView control but for the DataGridView it's quite simple. It's DataSource property allows multiple sources to populate (like DataSet, Xml, DataTable and such) like:

      Code:
              Dim ds As New DataSet
              Dim dt As New DataTable
              Dim xml As New Xml.XmlDocument
              Dim datagridview1 As DataGridView = Me.DataGridView1
              Dim datagridview2 As New DataGridView
      
              ds = datagridview1.DataSource
              dt = datagridview1.DataSource
              dt.WriteXml("c:\test.xml")
      
              datagridview2.DataSource = ds
              datagridview2.DataSource = dt
              datagridview2.DataSource = dt.ReadXml("c:\test.xml")

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Robjens,

        Your suggestion works well in the a desktop application; however a GridView is used in ASP.NET web development. This means that the VB.NET code creates all of the objects necessary to create the dynamic web page, sends the HTML output to the browser that requested it, and then destroys all of the objects.

        This means that the page would have to execute the code that creates the datasource every time a web browser connects to the web server (makes a request).

        This can be very costly and so instead of recreating the data source every time, you can create it the first time the page is requested and cache the data source for subsequent requests....thi s will save you a lot of time and resources.

        You can either cache it into ASP.NET's cache or you can store it in Session if you want to. There's a lot of options.

        -Frinny

        Comment

        Working...