473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Persist DataTable Values

Hi All:

I have a DataTable that I have defined Globally. I populate this datatable
dynamically with file/folder information that I read directly from the
server. I use this datatable information to bind mainly to a DataGrid, but
I would also like it to persist for the duration that I have a particular
page open. I seem to be losing this data either thru postbacks or by the
way I have coded it. Does anyone have any suggestions on how I can keep
this datatable in memory? TIA

--

Best regards

Paul Perot
President
Perot Solutions
pe************@earthlink.net
(770) 565 - 9151
(678) 852 - 7789 (c)

Nov 18 '05 #1
1 5412
You began by saying that the DataTable is "defined Globally." What does that
mean? Global to what? Obviously, it isn't truly global, or you wouldn't be
asking how to persist it. For example, if it was global to the Application
(in Application Cache, for example), you wouldn't need to persist it in any
other way. It would be truly global.

I only asked that to get you thinking along these lines, hopefully so that
this situation would not rear its ugly head again for you. The issue here is
scope. And a good understanding of ASP.Net scope is what is needed to
resolve it and any future issues of scope that may arise.

I suspect that by "defined Globally" you mean that you declared a variable
with Page scope, that is, defined in your Page class as a Field or Property
of your Page class, not inside a Method. However, the scope of such a
variable is global to only a single Page instance, and each Request for a
Page creates a new Page instance. A PostBack will not see the value of a
variable declared in a previous instance of this Page class, as the variable
will be re-initialized with the initialization of the Page class.

As you've defined the requirement that this variable be global to all
instances of this Page class (within the context of a single initial Request
and the related group of PostBacks), you could declare it as static (Shared
in VB.Net) in the Page class, or, if you want it re-initialized with each
non-PostBack (initial Request), you could put it into the Page's ViewState
or in Session. If you put it into ViewState, the size of it may affect the
time it takes for the Page to load in the browser (ViewState being a hidden
form field in the HTML form). The advantage of ViewState is that the
variable will disappear as soon as a different Page is Requested. If you use
Session, the Page will have to re-initialize the Session value when it is
Requested via non-PostBack (initial Request).

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Paul Perot" <pe************@earthlink.net> wrote in message
news:Cy***************@newsread2.news.atl.earthlin k.net...
Hi All:

I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the
server. I use this datatable information to bind mainly to a DataGrid, but I would also like it to persist for the duration that I have a particular
page open. I seem to be losing this data either thru postbacks or by the
way I have coded it. Does anyone have any suggestions on how I can keep
this datatable in memory? TIA

--

Best regards

Paul Perot
President
Perot Solutions
pe************@earthlink.net
(770) 565 - 9151
(678) 852 - 7789 (c)

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
3
by: Plumer | last post by:
Good morning everyone Using C# I create a bog-standard System.Data.DataTable which I then Add to a System.Data.Dataset (At the moment I'm in the guess-and-test phase so the table has only one...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
1
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
2
by: Richard Dixson | last post by:
Under ASP.NET (C#) I want to create a page that people can use to submit questions. This page will consist of a table with several rows of information, like: Name: Bill Smith Job title:...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
1
by: Ersin Gençtürk | last post by:
I have 2 typed data tables inherited from the same dataset schema One called : table A with an identity column x column x is constrained to be unique. Other one is : table B with an identity...
0
by: Anish G | last post by:
Hi, I have an issue with reading CSV files. I am to reading CSV file and putting it in a Datatable in C#. I am using a regular expression to read the values. Below is the code. Now, it reads...
5
by: Marc | last post by:
Ok, I am studying dot net, and I have a probably newbee sort of question again. I have made a form and a button that fills the gridview on the form. I also want to make a delete and edit button....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.