473,504 Members | 13,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET how to premanently store variable in code behind (C#)

2 New Member
Hi, The problem is I am trying to declare "protected DataSet universeSet = new DataSet();" in my C# page behind the asp page. The variable is declared on the top of the page. I want the information to be stored inside the variable universeSet so I can retrieve it for later use.

Whenever I click a button on my webpage (asp:Button or asp:ImageButton), the information in universeSet seem to be erased, I think this is because it is reloading the C# page, which the line "protected DataSet universeSet = new DataSet();" declares a fresh DataSet with no information inside.

How can I avoid reloading the variable, I can't take out " = new DataSet();" or I will get NullPointerException.

Thank you.
Apr 12 '07 #1
2 3929
prabunewindia
199 New Member
Hi, The problem is I am trying to declare "protected DataSet universeSet = new DataSet();" in my C# page behind the asp page. The variable is declared on the top of the page. I want the information to be stored inside the variable universeSet so I can retrieve it for later use.

Whenever I click a button on my webpage (asp:Button or asp:ImageButton), the information in universeSet seem to be erased, I think this is because it is reloading the C# page, which the line "protected DataSet universeSet = new DataSet();" declares a fresh DataSet with no information inside.

How can I avoid reloading the variable, I can't take out " = new DataSet();" or I will get NullPointerException.

Thank you.
hi friend,
just try with
" Protected static DataSet xxx= new DataSet();"
you may get ur need
Prabu
Apr 13 '07 #2
amitb
2 New Member
Wow thank you! It really did work! It's just a tiny code and was able to fix it, you're amazing, thanks.
Apr 13 '07 #3

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

Similar topics

2
6151
by: lsf_80 | last post by:
I am using ASP.net and C# as code behind. I wrote one function in the "page load" (code behind) and how can i call back the variable in the aspx page? Thank you. if i put response.write,...
3
2006
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
4
3498
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example...
1
9118
by: Machi | last post by:
let say i have a web form with a button on it ... when i click the button, it will pop up one small window to allow me to save a pdf file, everything is done using code behind as below ... however,...
3
2528
by: Ryan Taylor | last post by:
Hi. I need to be able to access a public code behind variable within my ASPX page. The reason is that I have a user control "Header" which defines a table layout, and is included in all my...
2
1329
by: rbutch | last post by:
does anyone know of a good place to go to get some ideas on datalists? im building a web app, in asp.net (vb.net) and displaying data in a data list. i want to be able to select any one of the...
7
2872
by: Alan Silver | last post by:
Hello, I am just looking at VWD and seeing what needs doing to take an existing site I've written by hand and importing it into VWD. I've already discovered that I need to rename my code-behind...
3
3928
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from...
1
1798
by: kelvinweb | last post by:
Hi All, Is it possible to using variable store container.dataitem in ItemTemplate ?? For example. <ItemTemplate> <% Dim x x = container.dataitem("LineNo")
0
7098
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...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
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...
0
5610
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,...
0
4698
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...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.