Click to See Complete Forum and Search --> : [RESOLVED] Updating a form, Postback, general confusion


Toot
January 9th, 2008, 09:19 AM
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:
if (IsPostBack)
{
LoadSelectedInfo();
}
else
{
LoadList();
SelectFirst();
LoadSelectedInfo();
}
ButtonClick goes something like this:
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

Toot
January 9th, 2008, 03:18 PM
Duh - ListBox_SelectedIndexChanged, not Page_Load !!

Yeorwned
January 9th, 2008, 03:20 PM
Did you rep yourself?