TextBox postback problem

J

John Cosmas

I have a form that has a listbox on the top that is bound to a header table.
When the page first loads, it paints the adjacent textboxes with data from
the details table. However, when I postback the page with a new selected
from the header table, the textboxes is not loaded with the new details.
During DEBUG, I could actually see the values as it loops through the fields
but it never paints the details into the textboxes after the page is
completely rendered. I then purposely added a label control onto the form,
and the values are always painted correctly after each postback. The
textboxes, has its initial value. I also tried clearing it first.
 
J

John Saunders

John Cosmas said:
I have a form that has a listbox on the top that is bound to a header table.
When the page first loads, it paints the adjacent textboxes with data from
the details table. However, when I postback the page with a new selected
from the header table, the textboxes is not loaded with the new details.
During DEBUG, I could actually see the values as it loops through the fields
but it never paints the details into the textboxes after the page is
completely rendered. I then purposely added a label control onto the form,
and the values are always painted correctly after each postback. The
textboxes, has its initial value. I also tried clearing it first.

Some code would help us understand your problem better...

Are you setting the TextBoxes in your listbox's SelectedIndexChanged event
handler? That should work.
 
J

John Cosmas

If the label is loaded with the correct information, why is the textbox not
loaded the same?
 
J

John Cosmas

Already did. Remember, the problem is with the textbox control. When the
page is posted back, the data is fetched and the test label I included is
painted/refreshed with the data. But, the textboxes retains its old value.
 
W

WJ

John Cosmas said:
Already did. Remember, the problem is with the textbox control. When the
page is posted back, the data is fetched and the test label I included is
painted/refreshed with the data. But, the textboxes retains its old value.

I do have applications that do this type of stuffs and they all work this
way. Since "Code behind" is located @your server. Without enabling postback
on the ListBox control, there is noway for the event handler to be invoked
to fill your TextBox control unless you use JS on client side! The only
thing I can think of is how your Page_Load event PostBack your Text control
? Here is what I do on all my applications on the Page_Load event handler:

c#

If(!IsPostBack)
{
TextBox1.text=ListBox.SelectedItem.Value.ToString();
}

This way, you only initialize your textbox 1st time only.

If this does not help, then your page must be corrupted somewhere, and this
does happen from time-2-time. If so, I would rebuild the page from scratch

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top