i am trying to change textbox value that i retrieved. I have a form which contains, a combobox from ajaxcontroltoolkit, a button to submit, a textbox for inserting comments. To beginning when i change a combobox value, automatically, the comment stored
in database is filled in textbox. Now even i change this comment, i still have older comment which is retrieved from database, new comment is never stored.
The autopostback on textbox is false. I tried to make it in true, no change. I tried to implement textchanged event. Same result.
When i add a test on ispostback property same result.
Here is some code:
try
{
CbNomContact.Enabled = true;
if (cbMission.SelectedValue.ToString().Contains("Numéro:"))
{
first = cbMission.Text.IndexOf("Numéro:");
numSA = cbMission.SelectedValue.ToString().Substring(first + 7, first + 2);
CbNomContact.DataSource = BindContacts(numSA);
CbNomContact.DataBind();
CbNomContact.SelectedIndexChanged += new EventHandler(CbNomContact_SelectedIndexChanged);
The change in combobox call this method. the submit method attached on button call implicitly again this method and overwrite the value of comment. I have a autopostback on true in combobox. I tried to make it at false, no change appear.
cdamy
Member
2 Points
6 Posts
postback problem
Dec 26, 2012 01:08 PM|LINK
Hello,
i am trying to change textbox value that i retrieved. I have a form which contains, a combobox from ajaxcontroltoolkit, a button to submit, a textbox for inserting comments. To beginning when i change a combobox value, automatically, the comment stored in database is filled in textbox. Now even i change this comment, i still have older comment which is retrieved from database, new comment is never stored.
The autopostback on textbox is false. I tried to make it in true, no change. I tried to implement textchanged event. Same result.
When i add a test on ispostback property same result.
Here is some code:
try
{
CbNomContact.Enabled = true;
if (cbMission.SelectedValue.ToString().Contains("Numéro:"))
{
first = cbMission.Text.IndexOf("Numéro:");
numSA = cbMission.SelectedValue.ToString().Substring(first + 7, first + 2);
CbNomContact.DataSource = BindContacts(numSA);
CbNomContact.DataBind();
CbNomContact.SelectedIndexChanged += new EventHandler(CbNomContact_SelectedIndexChanged);
txbxdesc.Text = RetrieveServiceAppointmentDescription(numSA);
txbxObs.Text = RetrieveServiceAppointmentObservation(numSA);
}
}
catch (Exception e) {
e.ToString();
}
The change in combobox call this method. the submit method attached on button call implicitly again this method and overwrite the value of comment. I have a autopostback on true in combobox. I tried to make it at false, no change appear.
Any idea?
Thanks
nikunjnandan...
Participant
882 Points
223 Posts
Re: postback problem
Dec 27, 2012 04:44 AM|LINK
Hii,
R u getting value in text box in page load event??
If yes then try to put your code in If Not is postback and then check.
I think this is the cause when you page is getting postback and pageload event is fired and your text get value from your database.
Nikunj Nandaniya
My Blog
cdamy
Member
2 Points
6 Posts
Re: postback problem
Dec 27, 2012 07:48 AM|LINK
Hello,
thank for u r reply. this is my page load handler,
protected void Page_Load(object sender, EventArgs e)
{
Response.AddHeader("pragma", "no-cache");
Response.CacheControl = "no-cache";
BindSA();
}
i tried before:
if(!IsPostBack){
BindSA();
}
When i chose this option the SelectedIndexChanged on combobox did not work .
Here is few code of BindSA():
string[] missions = RetrieveServiceAppointments();
if (missions != null)
{
cbMission.DataSource = missions;
cbMission.DataBind();
cbMission.SelectedIndexChanged+=new EventHandler(cbMission_SelectedIndexChanged);
}
Thanks