[RESOLVED] Updating a form, Postback, general confusion
I have a form containing a dropdownlist. Whatever is selected in the dropdownlist gets loaded in the subsequent textboxes, checkboxes, etc. I then have a button to be used to apply changes.
Page_Load goes something like this:
Code:
if (IsPostBack)
{
LoadSelectedInfo();
}
else
{
LoadList();
SelectFirst();
LoadSelectedInfo();
}
ButtonClick goes something like this:
Code:
if (List.SelectedIndex >= 0)
{
string strSelected = List.SelectedValue;
bool bChanged = false;
CurrentInfo = LoadInfo(strSelected);
if (FirstTextBox.Text.CompareTo(CurrentInfo.FirstText) != 0)
{
CurrentInfo.FirstText = FirstTextBox.Text;
bChanged = true;
}
if (FirstCheckBox.Checked != CurrentInfo.FirstCheck)
{
CurrentInfo.FirstCheck = FirstCheckBox.Checked;
bChanged = true;
}
if (bChanged)
{
UpdateDatabase();
}
}
The problem is that the Page_Load fires which loads the current info into the form, so when the subsequent Button_Click event fires, the values to be updating with have been filled so the values to be updated are lost.
How is this kind of stuff normally achieved? Any ideas? Have I been clear in my explanation?
Thanks for your time,
T
Re: Updating a form, Postback, general confusion
Duh - ListBox_SelectedIndexChanged, not Page_Load !!
Re: [RESOLVED] Updating a form, Postback, general confusion