Data cannot be updated during an update function today. I set the breakpoint to trace and found this problem.
First lookCode:
Protected Void Page_load ( Object Sender, eventargs E)
{
// Before ispostback is added, teacher. Update (txtname. Text); The txtname. Text here will never change,
// Because BIND () is executed first and then btnok_click ();
If ( ! Ispostback)
BIND ();
}
Private Void BIND ()
{
Txtname. Text = " Hello " ;
}
Protected Void Btnok_click ( Object Sender, eventargs E)
{
Teacher. Update (txtname. Text );
}
When I click the update button, the data is always unchanged, and it can be updated simply by changing to teacher. Update ("hi.
It's really strange that when I set a breakpoint for debugging, I found that when I didn't add ispostback to the judgment, I first executed page_load ();
Then, run btnok_click (). After being depressed for a long time, write it out and remind other friends.