Hi,
In a webform I have two textBoxes. In a formload event I will retrieve some data from db and will assign it to textboxes as below
textBox1.Text=dr.getValue(0).ToString(); (Sachi)
textBox2.Text=dr.getValue(1).ToString(); (Vasista)
Now in a button click event I will make some correction in the same textbox and I will asign those values to two string variables as below
string Fname=textBox1.Text.ToString(); (Sachin)
string Lname=textBox2.Text .ToString(); (Vasishta)
but when I checked the values of these 2 string variables using breakpoint the values were not changed, it was showing the old values which were retrieved from the db.
Thanks
Loading
Kirtan PatelPosted Nov 14, 2009, 3:29 AM
you should Write Code Like Below
In FormLoad Event here !IsPostback us Necessary then it will work correctly
check "Do you like this answer check box" if it helps you :)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Text = dr.getValue(0).ToString();TextBox2.Text = dr.getValue(1).ToString();
}
}
sachi vasishtaPosted Nov 14, 2009, 4:30 AM