By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,349 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

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

P: 1
Hi All,

I would like to save Gridview with all of the columns value and reload the same grid without using database??
Apr 30 '10 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 9,731
You would cache the DataSource that you use for the GridView and reuse that cached value instead of going to the database again.

Apr 30 '10 #2

P: 37
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:

Expand|Select|Wrap|Line Numbers
  1.         Dim ds As New DataSet
  2.         Dim dt As New DataTable
  3.         Dim xml As New Xml.XmlDocument
  4.         Dim datagridview1 As DataGridView = Me.DataGridView1
  5.         Dim datagridview2 As New DataGridView
  7.         ds = datagridview1.DataSource
  8.         dt = datagridview1.DataSource
  9.         dt.WriteXml("c:\test.xml")
  11.         datagridview2.DataSource = ds
  12.         datagridview2.DataSource = dt
  13.         datagridview2.DataSource = dt.ReadXml("c:\test.xml")
Apr 30 '10 #3

Expert Mod 5K+
P: 9,731

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....this 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.

May 3 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.