473,800 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newb textbox question

I have a textbox on a form that is populated from the database when the form
loads. When I check textbox.Text when the user clicks my submit button, the
value is always what it was when the form loaded, no matter of what the user
changed the text to. Any suggestions?

protected void Page_Load(objec t sender, EventArgs e)
{
DataSet ds = Customers.GetCu stomer(Request["Customer"]);
if (ds.Tables[0].Rows.Count == 0)
return;

name.Text = ds.Tables[0].Rows[0][0].ToString();
phone.Text = ds.Tables[0].Rows[0][1].ToString();
contact.Text = ds.Tables[0].Rows[0][2].ToString();
address.Text = ds.Tables[0].Rows[0][3].ToString();
city.Text = ds.Tables[0].Rows[0][4].ToString();
state.SelectedV alue = ds.Tables[0].Rows[0][5].ToString();
zip.Text = ds.Tables[0].Rows[0][6].ToString();
notes.Text = ds.Tables[0].Rows[0][7].ToString();
}
protected void editSubmit_Clic k(object sender, EventArgs e)
{
if (editSubmit.Tex t == "Edit")
{
name.ReadOnly = false;
phone.ReadOnly = false;
contact.ReadOnl y = false;
address.ReadOnl y = false;
city.ReadOnly = false;
state.Enabled = true;
zip.ReadOnly = false;
notes.ReadOnly = false;

editSubmit.Text = "Submit";
}
else
{
name.ReadOnly = true;
phone.ReadOnly = true;
contact.ReadOnl y = true;
address.ReadOnl y = true;
city.ReadOnly = true;
state.Enabled = false;
zip.ReadOnly = true;
notes.ReadOnly = true;

editSubmit.Text = "Edit";
string s = name.Text;

Response.Redire ct("CustomerDet ails.aspx?Custo mer=" + s, false);
}
}
Jan 31 '06 #1
2 1490
You're resetting the textbox each time you load the page. Remember, the
clicking 'submit' still causes the Page_Load event to fire. You want to wrap
your load code with an IsPostBack check as follows:

protected void Page_Load(objec t sender, EventArgs e)
{
//Note the IsPostBack call
if(!this.IsPost Back)
{
DataSet ds = Customers.GetCu stomer(Request["Customer"]);
if (ds.Tables[0].Rows.Count == 0)
return;

name.Text = ds.Tables[0].Rows[0][0].ToString();
phone.Text = ds.Tables[0].Rows[0][1].ToString();
contact.Text = ds.Tables[0].Rows[0][2].ToString();
address.Text = ds.Tables[0].Rows[0][3].ToString();
city.Text = ds.Tables[0].Rows[0][4].ToString();
state.SelectedV alue = ds.Tables[0].Rows[0][5].ToString();
zip.Text = ds.Tables[0].Rows[0][6].ToString();
notes.Text = ds.Tables[0].Rows[0][7].ToString();
}
}

HTH,

Matt Dinovo
"Eric" <Er**@discussio ns.microsoft.co m> wrote in message
news:DC******** *************** ***********@mic rosoft.com...
I have a textbox on a form that is populated from the database when the
form
loads. When I check textbox.Text when the user clicks my submit button,
the
value is always what it was when the form loaded, no matter of what the
user
changed the text to. Any suggestions?

protected void Page_Load(objec t sender, EventArgs e)
{
DataSet ds = Customers.GetCu stomer(Request["Customer"]);
if (ds.Tables[0].Rows.Count == 0)
return;

name.Text = ds.Tables[0].Rows[0][0].ToString();
phone.Text = ds.Tables[0].Rows[0][1].ToString();
contact.Text = ds.Tables[0].Rows[0][2].ToString();
address.Text = ds.Tables[0].Rows[0][3].ToString();
city.Text = ds.Tables[0].Rows[0][4].ToString();
state.SelectedV alue = ds.Tables[0].Rows[0][5].ToString();
zip.Text = ds.Tables[0].Rows[0][6].ToString();
notes.Text = ds.Tables[0].Rows[0][7].ToString();
}
protected void editSubmit_Clic k(object sender, EventArgs e)
{
if (editSubmit.Tex t == "Edit")
{
name.ReadOnly = false;
phone.ReadOnly = false;
contact.ReadOnl y = false;
address.ReadOnl y = false;
city.ReadOnly = false;
state.Enabled = true;
zip.ReadOnly = false;
notes.ReadOnly = false;

editSubmit.Text = "Submit";
}
else
{
name.ReadOnly = true;
phone.ReadOnly = true;
contact.ReadOnl y = true;
address.ReadOnl y = true;
city.ReadOnly = true;
state.Enabled = false;
zip.ReadOnly = true;
notes.ReadOnly = true;

editSubmit.Text = "Edit";
string s = name.Text;

Response.Redire ct("CustomerDet ails.aspx?Custo mer=" + s, false);
}
}

Jan 31 '06 #2
protected void Page_Load(objec t sender, EventArgs e)
{
if(!IsPostBack)
{
DataSet ds = Customers.GetCu stomer(Request["Customer"]);
if (ds.Tables[0].Rows.Count == 0)
return;

name.Text = ds.Tables[0].Rows[0][0].ToString();
phone.Text = ds.Tables[0].Rows[0][1].ToString();
contact.Text = ds.Tables[0].Rows[0][2].ToString();
address.Text = ds.Tables[0].Rows[0][3].ToString();
city.Text = ds.Tables[0].Rows[0][4].ToString();
state.SelectedV alue = ds.Tables[0].Rows[0][5].ToString();
zip.Text = ds.Tables[0].Rows[0][6].ToString();
notes.Text = ds.Tables[0].Rows[0][7].ToString();
} // IsPostback==tru e means the page is posted back, and you DO NOT
// want to use the original values.
}
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Eric" wrote:
I have a textbox on a form that is populated from the database when the form
loads. When I check textbox.Text when the user clicks my submit button, the
value is always what it was when the form loaded, no matter of what the user
changed the text to. Any suggestions?

protected void Page_Load(objec t sender, EventArgs e)
{
DataSet ds = Customers.GetCu stomer(Request["Customer"]);
if (ds.Tables[0].Rows.Count == 0)
return;

name.Text = ds.Tables[0].Rows[0][0].ToString();
phone.Text = ds.Tables[0].Rows[0][1].ToString();
contact.Text = ds.Tables[0].Rows[0][2].ToString();
address.Text = ds.Tables[0].Rows[0][3].ToString();
city.Text = ds.Tables[0].Rows[0][4].ToString();
state.SelectedV alue = ds.Tables[0].Rows[0][5].ToString();
zip.Text = ds.Tables[0].Rows[0][6].ToString();
notes.Text = ds.Tables[0].Rows[0][7].ToString();
}
protected void editSubmit_Clic k(object sender, EventArgs e)
{
if (editSubmit.Tex t == "Edit")
{
name.ReadOnly = false;
phone.ReadOnly = false;
contact.ReadOnl y = false;
address.ReadOnl y = false;
city.ReadOnly = false;
state.Enabled = true;
zip.ReadOnly = false;
notes.ReadOnly = false;

editSubmit.Text = "Submit";
}
else
{
name.ReadOnly = true;
phone.ReadOnly = true;
contact.ReadOnl y = true;
address.ReadOnl y = true;
city.ReadOnly = true;
state.Enabled = false;
zip.ReadOnly = true;
notes.ReadOnly = true;

editSubmit.Text = "Edit";
string s = name.Text;

Response.Redire ct("CustomerDet ails.aspx?Custo mer=" + s, false);
}
}

Jan 31 '06 #3

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

Similar topics

0
2133
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No Preference", I'd like to uncheck
0
1645
by: David E. | last post by:
So as a programmer, what's the best thing to study? EJB? How much of the J2EE or Enterprise architecture is necessary to no? I guess I need a good overview for a newb like me... thanks.. -- N0 Spam Ema|l address. Please, when replying directly, delete "NSPAMO" from email address. Thanks
3
1762
by: Walter | last post by:
But I'm stumped..... I've got a windows 2000 server and I am trying to set up PHPBB on it using a mysql database.. I am very inexperienced on this..... Ive installed mysql V4.0.20d and I can get it up and running. I then run winmysqladmin V1.4 (the mysql service is running) When I go to databases inside the admin, it shows on the left side the name of the server and IP address and it has a 'test' database listed below it..... From...
3
1834
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No Preference", I'd like to uncheck
6
1685
by: Sean Berry | last post by:
Hello all I have build a list that contains data in the form below -- simplified for question -- myList = ,, ...] I have a function which takes value3 from the lists above and returns another value. I want to use this returned value to sort the lists. So, my resultant list would be ordered by the return value of the
1
1099
by: Qwert | last post by:
Hello, two questions about the following code (.aspx file): Why doesn't the 'Text' property of control 'Label1' get changed in the function 'SetLabelText()'? How do I trigger the 'SetLabelText()' function when the mouse moves over the label control? The line code as below does not function. Thanks.
2
922
by: Adriano | last post by:
hello, I have TextBox1 and TextBox2 in my win. app, is it possibe to make my "Left Arrow Key" act like "Shift Tab"(focus the previous control) only in the case the cursor comes to the begining of the text inside the textbox??? (sort of MsWord table behaviour) thanks in advance, Adriano
6
1946
by: tommydogs | last post by:
I am just starting out with AxWebBrowser and need help with a simple application. I just want to navigate to a web page, then read in source code. Here's what I have so far: Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load AxWebBrowser1.Navigate("http://www.google.com") End Sub
2
14850
by: python programming newb | last post by:
Hi all, first post. I'm new to python and tkinter. I'm trying to write a program that opens the root window with a button that then opens a toplevel window that then has it's own widgets. I can get the new toplevel window to open but none of the widgets appear. The console gives me: AttributeError: 'NewWindow' object has no attribute 'tk' Here's my code:
0
9690
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
10274
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...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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
9085
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
6811
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();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3
2945
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.