M
Mike Lerch
I am wondering this: why do texboxes in the main body of a form act
differently to postback than textboxes in a repeater on the form? I
posted earlier about not being able to capture a user's input from a
textbox, and I finally figured out what was happening: the textbox
was bound, and it was getting stuffed with the database value both on
the first load of the form AND after the user had changed stuff and
clicked the button that fired the postback.
So, if I basically added this:
if (!Page.IsPostBack)
{
Page.DataBind();
}
and now those textboxes are working fine. But I really don't
understand this: the textboxes within the repeater did and still do
work as I expected. If I change something in them, I can step through
the code and watch as they are re-databound, and THEN the OnChange
event fires. But where the OnChange event of the main form's
textboxes reveals that the textboxes' Text is whatever was originally
in the database, the textboxes within the repeater are showing the
user's text. HOW IS THIS POSSIBLE?
Any help in understanding this is greatly appreciated, as I think I
see how to make everything work the way I want, but I really want to
understand WHY this is.
Also, if there are any great resources describing the interrelations
of databinding, Page.IsPostBack and viewstate, I'd really like to know
them!
TIA,
Lerch
differently to postback than textboxes in a repeater on the form? I
posted earlier about not being able to capture a user's input from a
textbox, and I finally figured out what was happening: the textbox
was bound, and it was getting stuffed with the database value both on
the first load of the form AND after the user had changed stuff and
clicked the button that fired the postback.
So, if I basically added this:
if (!Page.IsPostBack)
{
Page.DataBind();
}
and now those textboxes are working fine. But I really don't
understand this: the textboxes within the repeater did and still do
work as I expected. If I change something in them, I can step through
the code and watch as they are re-databound, and THEN the OnChange
event fires. But where the OnChange event of the main form's
textboxes reveals that the textboxes' Text is whatever was originally
in the database, the textboxes within the repeater are showing the
user's text. HOW IS THIS POSSIBLE?
Any help in understanding this is greatly appreciated, as I think I
see how to make everything work the way I want, but I really want to
understand WHY this is.
Also, if there are any great resources describing the interrelations
of databinding, Page.IsPostBack and viewstate, I'd really like to know
them!
TIA,
Lerch