|
-
January 9th, 2008, 09:19 AM
#1
[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
Some cause happiness wherever they go; others, whenever they go.
-
January 9th, 2008, 03:18 PM
#2
Re: Updating a form, Postback, general confusion
Duh - ListBox_SelectedIndexChanged, not Page_Load !!
Some cause happiness wherever they go; others, whenever they go.
-
January 9th, 2008, 03:20 PM
#3
Re: [RESOLVED] Updating a form, Postback, general confusion
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|