474,082 Members | 5,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clearing Variables

I'm new to C# and I'm dynamically creating a table control that contains a
text control inside one of the cells. I load the values of each text field
with an SQL call. The form is simple and I'm getting HR information from the
DB. When the page loads the first time and looks up the customers
information based on his/her NT login ID everything works great. I want to
have the ability to change the NT login ID in the form and then repost the
page/information back to itself, lookup the NT login in the DB and then post
the new information in the form.

This is were I'm running into problems. When I change the NT login name, the
information is not being updated. When I tracing through the code in the
debugger, I can see the variables being updated with the new information
from the database, but the fields in my page don't update???? Has anyone
else seen this problem? Is there anything I can do to clear these fields
before I update them? I suspect the problem is due to the way C# maintains
sessions and session variables, but I'm not sure.


Nov 15 '05 #1
1 2351
Hi,

Ensure you call the Page.DataBind() method upon postback. If you don't, the
controls will most likely restore their old values saved to the page's
viewstate.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Tyros" <mp*****@austin .rr.com> wrote in message
news:Nn******** **********@twis ter.austin.rr.c om...
I'm new to C# and I'm dynamically creating a table control that contains a
text control inside one of the cells. I load the values of each text field
with an SQL call. The form is simple and I'm getting HR information from the DB. When the page loads the first time and looks up the customers
information based on his/her NT login ID everything works great. I want to
have the ability to change the NT login ID in the form and then repost the
page/information back to itself, lookup the NT login in the DB and then post the new information in the form.

This is were I'm running into problems. When I change the NT login name, the information is not being updated. When I tracing through the code in the
debugger, I can see the variables being updated with the new information
from the database, but the fields in my page don't update???? Has anyone
else seen this problem? Is there anything I can do to clear these fields
before I update them? I suspect the problem is due to the way C# maintains
sessions and session variables, but I'm not sure.


Nov 15 '05 #2

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

Similar topics

9
1705
by: lallous | last post by:
Hello, Given: class X { int x, y; // and many many more.... X() { memset((void*)this, 0, sizeof(X));
2
2154
by: Andrew Poulos | last post by:
If I'm using DOM methods to dynamically create elements in a page is it necessary for me to clear whatever variables I used to create the elements when the page unloads? I'm reading bits and pieces which seems to indicate that they'll be memory issues if I don't. Andrew Poulos
12
10197
by: Hans B | last post by:
Please bear with me if I ask silly questions....I am a somewhat newbie to the C language.... If I had: struct test1_{ unsigned char mycount1; unsigned short mycount2; unsigned short mycount3;
0
3006
by: PD | last post by:
I am trying to stream out a PDF file via the response object and when I execute the code it always brings up the first document that I pulled up.Even when I step through the code, I can see the new values in theData string array (see code below), but it serves up the first document that I had run this code with. I streamed theData into a text file to look at the values and it contained the appropriate ones for the new document. Even when I...
2
1463
by: Leszek Gruszka | last post by:
My question is - how to clear variable in code? I don't want to declare different variables for all my functions... I've got 20 functions, that are running in application everytime i run it. In every function i'm using the same variable. My code read from registry values of keys. Everything is ok, but: 1) function is running and reading from registry (key exist) 2) next reading (key doesn't exist, but code take value from previous...
2
2518
by: Dan | last post by:
In C, it's usually necessary to clear the memory in structures before passing them to certain WinAPI functions. How would one do that in VB.NET?
4
4479
by: Amy | last post by:
I'm having a problem with clearing my session variables. I'm using session variables to pass data from a web form to a pdf generator. The problem comes in when a user goes back to the original page and takes data out of the field - the session variable is persisting. i tried the following, and it didn't work - I'm not sure where to go from here. Any advice would be appreciated. The string being passed is both the variable name and the...
7
3446
by: Pam Poulos | last post by:
I have a form where users input some dates, these dates are then written to date variables. I need to clear out the date variables with either an empty string or a null value. Currently, I am using 12:00 AM to clear out the date value, however this is now causing confusion. Can anyone tell me out to clear out the variable so it is empty. Thanks so much Pam
6
5012
by: =?Utf-8?B?R2Vv?= | last post by:
Hi, I use lots of sessions. I want to clear the unwanted sessions when I leave a page. I cant use ViewState as it will slow down the pages. Could some one help me on this?
0
10634
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
12291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11693
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
11215
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
10412
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...
0
7969
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
6781
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5516
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
5018
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.