473,796 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5435
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******** *******@newsrea d2.news.atl.ear thlink.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
2256
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 DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this is in ASP.NET). Is it possible to have data in a datable before attaching at DataAdapter? I'm a...
3
11563
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 field called "ID" which is Int32.) I need to save this table to an SQL Server database. The Dataset/DataAdapter approach does not seem to provide for this requirement. The logic appears to be based on the
1
2974
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 a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
1
2010
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: Developer Address: 123 Main Street. After the table of information will be the web form. So basically I want to display the table and then have the web form.
2
2364
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: Developer Address: 123 Main Street. After the table of information will be the web form. So basically I want to display the table and then have the web form.
0
3169
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 datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
1
2267
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 column x There are some rows in table A and table B. When I want to add a row from table A to table B I use the function TableA.ImportRow(TableB.rows); // for example
0
2197
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 CSV file without any issues only if all the fields are not null. If any field is blank, it moves the values to the left and displays the value under invalid column. Example is shown below: A part of CSV file. I am reading the first row as...
5
1435
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. But everytime I click the delete or edit button, the gridview disappears again. I guess it is not recreated after a page reload, but what can I do to fix this? This is my code: using System; using System.Data;
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.